Skip to content

Commit

Permalink
version update, debugging SQL insert
Browse files Browse the repository at this point in the history
  • Loading branch information
LabAsim committed Dec 21, 2022
1 parent 3f9af12 commit 6a8f514
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions App.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,21 @@ def save_dataclasses_to_sqlite(self):
""", list_to_insert)
# Remember to commit the transaction after executing INSERT.
con.commit()
with open('example.txt', 'a+', encoding="utf-8") as file:
file.write(f"""
INSERT INTO news VALUES('{text_id}','{tuple_dataclass[0]}','{tuple_dataclass[1]}',
'{tuple_dataclass[2]}', '{tuple_dataclass[3]}', '{tuple_dataclass[4]}',
'{tuple_dataclass[5]}','{tuple_dataclass[6]}','{tuple_dataclass[7]}',
'{tuple_dataclass[8]})
ON CONFLICT(news.url) DO UPDATE SET
date = '{str(tuple_dataclass[0])}',
main_content = '{str(tuple_dataclass[2])}',
summary = '{str(tuple_dataclass[3])}',
author = '{tuple_dataclass[5]}',,
author_url = '{tuple_dataclass[6]}',
category = '{tuple_dataclass[8]}';
""")
if self.debug:
with open('example.txt', 'a+', encoding="utf-8") as file:
file.write(f"""
INSERT INTO news VALUES('{text_id}','{tuple_dataclass[0]}','{tuple_dataclass[1]}',
'{tuple_dataclass[2]}', '{tuple_dataclass[3]}', '{tuple_dataclass[4]}',
'{tuple_dataclass[5]}','{tuple_dataclass[6]}','{tuple_dataclass[7]}',
'{tuple_dataclass[8]})
ON CONFLICT(news.url) DO UPDATE SET
date = '{str(tuple_dataclass[0])}',
main_content = '{str(tuple_dataclass[2])}',
summary = '{str(tuple_dataclass[3])}',
author = '{tuple_dataclass[5]}',,
author_url = '{tuple_dataclass[6]}',
category = '{tuple_dataclass[8]}';
""")
cur.execute("""SELECT * FROM news ORDER BY date_unix DESC""")
for number, a in enumerate(cur.fetchall()):
if number <= 5:
Expand Down
2 changes: 1 addition & 1 deletion source/version/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "30-11-2022"
"version": "21-12-2022"
}

0 comments on commit 6a8f514

Please sign in to comment.