|
@@ -79,6 +79,31 @@ async def add_client_info(ci:client_info):
|
|
return return_code
|
|
return return_code
|
|
|
|
|
|
|
|
|
|
|
|
+def make_ci_df():
|
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
|
|
|
|
+
|
|
|
|
+ statement = 'SELECT * FROM client_info ORDER BY time_stamp DESC'
|
|
|
|
+ #2021-05-23 15:57:43
|
|
|
|
+ df = pd.DataFrame()
|
|
|
|
+ for row in db.query(statement):
|
|
|
|
+ date_format = "%Y-%M-%d %H:%M:%S"
|
|
|
|
+
|
|
|
|
+ #fdate = datetime.strptime(row['ts_date'],date_format)
|
|
|
|
+ fdate = row['time_stamp'].strftime('%Y-%m-%d')
|
|
|
|
|
|
|
|
+ df = df.append({'serial id':row['id'],'姓名':row['name'],'公司':row['organization']
|
|
|
|
+ ,'職稱':row['position'],'電話':row['phone'],"e-mail":row['email'],'已匯款,後五碼':row['cert_last5']
|
|
|
|
+ ,'如何知道這個課程':row['where_learn'],'爲什麼想報名':row['why_sign']}, ignore_index=True)
|
|
|
|
|
|
-
|
|
|
|
|
|
+def save_sheet(df,filename,tabname,startpos='A1'):
|
|
|
|
+
|
|
|
|
+ scope = ['https://spreadsheets.google.com/feeds',
|
|
|
|
+ 'https://www.googleapis.com/auth/drive']
|
|
|
|
+
|
|
|
|
+# credentials = ServiceAccountCredentials.from_json_keyfile_name('c:\\keys\\spread2.json', scope)
|
|
|
|
+ credentials = ServiceAccountCredentials.from_json_keyfile_name('spread2.json', scope)
|
|
|
|
+
|
|
|
|
+ gc = gspread.authorize(credentials)
|
|
|
|
+ spread = Spread(filename,creds=credentials)
|
|
|
|
+
|
|
|
|
+ spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)
|