added function to insert translated list of content
This commit is contained in:
@@ -171,6 +171,23 @@ def insert_list(username_list, timestamp_list, content_list):
|
||||
except Exception as e:
|
||||
logging.warning(e)
|
||||
|
||||
def insert_translated_list(content_list, id_list):
|
||||
with Data_table() as dt:
|
||||
for id, content in zip(id_list, content_list):
|
||||
try:
|
||||
val_dict = {
|
||||
'id': id,
|
||||
'content_en': content
|
||||
}
|
||||
query = (
|
||||
f'UPDATE {dt._name} '
|
||||
' SET content_en = (%(content_en)s) '
|
||||
'WHERE id = (%(id)s) '
|
||||
)
|
||||
dt.execute(query, val_dict)
|
||||
except Exception as e:
|
||||
print(f'error when updating database: {e}')
|
||||
|
||||
def get_content():
|
||||
with Data_table() as dt:
|
||||
query = f'SELECT * FROM {dt._name} ORDER BY time DESC '
|
||||
|
||||
Reference in New Issue
Block a user