|
|
| import sqlite3
|
| import os
|
|
|
| def dump_sqlite_to_sql(db_path, output_path):
|
|
|
| if not os.path.exists(db_path):
|
| print(f"Error: Database file '{db_path}' not found.")
|
| return
|
|
|
| try:
|
|
|
| conn = sqlite3.connect(db_path)
|
|
|
|
|
| with open(output_path, 'w', encoding='utf-8') as f:
|
|
|
| for line in conn.iterdump():
|
| f.write('%s\n' % line)
|
|
|
| print(f"Successfully dumped '{db_path}' to '{output_path}'.")
|
|
|
| conn.close()
|
| except Exception as e:
|
| print(f"An error occurred: {e}")
|
|
|
| if __name__ == "__main__":
|
| db_file = "attendr.db"
|
| sql_file = "attendr.sql"
|
|
|
|
|
| current_dir = os.getcwd()
|
| db_path = os.path.join(current_dir, db_file)
|
| output_path = os.path.join(current_dir, sql_file)
|
|
|
| print(f"Dumping {db_path}...")
|
| dump_sqlite_to_sql(db_path, output_path)
|
|
|