Skip to content

Commit

Permalink
chore: Delete existing SQLite file before conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanBayoumi committed May 29, 2024
1 parent b34fe89 commit cb79ab3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Binary file modified result/ar.sqlite
Binary file not shown.
Binary file modified result/en.sqlite
Binary file not shown.
7 changes: 6 additions & 1 deletion scripts/convert_to_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@


def convert_json_to_sqlite(json_file, sqlite_file):
# Delete the SQLite file if it exists
if os.path.exists(sqlite_file):
os.remove(sqlite_file)
print(f"Deleted existing file {sqlite_file}")

with open(json_file, "r", encoding="utf-8") as f:
data = json.load(f)

Expand All @@ -12,7 +17,7 @@ def convert_json_to_sqlite(json_file, sqlite_file):

headers = data[0].keys()
columns = ", ".join([f'"{header}"' for header in headers])
cursor.execute(f"CREATE TABLE IF NOT EXISTS morning_and_evening ({columns})")
cursor.execute(f"CREATE TABLE morning_and_evening ({columns})")

for entry in data:
placeholders = ", ".join(["?"] * len(headers))
Expand Down

0 comments on commit cb79ab3

Please sign in to comment.