在Hive查询中传递python列表作为参数

时间:2019-12-24 05:40:52

标签: hive

   from tkinter import *
    import pyodbc
    with pyodbc.connect("DSN=ffff", autocommit=True) as conn:
          df2 = pd.read_sql("SELECT * FROM holdingsummarysaaas", conn)
          list46 = []
          for md in df2['clientcode']:
               list46.append(md)
          print(list46)
          result = []
          for i in list46:
              if i not in result:
              result.append(i)
          print(result)
          #list_no_nan = [x for x in result if pd.notnull(x)]
          #print(list_no_nan)
          #select name from studens where id in (%s)" % ",".join(map(str,mylist)
          #def fun():
          num1 = Entry(root)
          blank = Entry(root)
          Ans = (num1.get())
          blank.insert(0, Ans)
          if Ans in result:
              df2 = pd.read_sql('SELECT * FROM holdingsummary where ' + ' or '.join(('clientcode = ' 
              + str(n) for n in result)),conn)
              #df2 = pd.read_sql("SELECT * FROM holdingsummary  where clientcode = '" + Ans + "'", 
              conn)
              print(df2)

我正在从数据库中获取唯一的客户端代码,我希望用户输入很有趣
          函数应该访问结果列表(唯一的clientcode),检查列表中的每个clientcode           并检查结果列表中输入的客户代码是否相同,然后打开该客户代码。          例如:

Ans=='100014'  
         #df2 = pd.read_sql("SELECT * FROM holdingsummarysaaas  where clientcode = '100014', conn)

0 个答案:

没有答案