|
@@ -34,22 +34,14 @@ class DBDownload:
|
|
|
print('数据库连接成功!')
|
|
|
self.cursor = self.conn.cursor()
|
|
|
|
|
|
- def getdata(self,*param,tablename,sn,timename,st,sp):
|
|
|
+ def getdata(self,param,tablename,sn,timename,st,sp):
|
|
|
print('数据获取中......')
|
|
|
- param=list(param)
|
|
|
- str=''
|
|
|
- for i in range(len(param)):
|
|
|
- if i<1:
|
|
|
- str=str+param[i]
|
|
|
- else:
|
|
|
- str=str+','+param[i]
|
|
|
if self.mode==1:
|
|
|
- self.cursor.execute("select %s from %s where sn='%s' order by id desc limit 1" %(str,tablename,sn))
|
|
|
+ self.cursor.execute("select %s from %s where sn='%s' order by id desc limit 1" %(param,tablename,sn))
|
|
|
else:
|
|
|
- self.cursor.execute("select %s from %s where sn='%s' and %s between '%s' and '%s'" %(str,tablename,sn,timename,st,sp))
|
|
|
+ self.cursor.execute("select %s from %s where sn='%s' and %s between '%s' and '%s'" %(param,tablename,sn,timename,st,sp))
|
|
|
res = self.cursor.fetchall()
|
|
|
- df_res = pd.DataFrame(res, columns=param)
|
|
|
- df_res = df_res.reset_index(drop=True)
|
|
|
+ df_res = pd.DataFrame(res, columns=param.split(','))
|
|
|
return(df_res)
|
|
|
|
|
|
def close(self):
|