|
@@ -58,4 +58,27 @@ async def add_subclient_info():
|
|
|
result = []
|
|
|
for row in db.query(statement):
|
|
|
result += [{'id':row['id'],'email':row['email'],'timeStamp':row['timestamp']}]
|
|
|
- return result
|
|
|
+ return result
|
|
|
+
|
|
|
+
|
|
|
+def make_ci_df():
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/NFTBoard?charset=utf8mb4')
|
|
|
+ statement = 'SELECT * FROM Subscribe ORDER BY timestamp 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 = row['time_stamp'].strftime('%Y-%m-%d %H時 %M分')
|
|
|
+
|
|
|
+ df = df.append({'serial id':row['id'],'e-mail':row['email'],'登記時間':row['timestamp']}, ignore_index=True)
|
|
|
+
|
|
|
+ df = df[['serial id','e-mail','登記時間']]
|
|
|
+ save_sheet(df,'email_rec','Sheet1')
|
|
|
+
|
|
|
+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('spread2.json', scope)
|
|
|
+ gc = gspread.authorize(credentials)
|
|
|
+ spread = Spread(filename,creds=credentials)
|
|
|
+ spread.df_to_sheet(df, index=True, sheet=tabname, start=startpos, replace=True)
|