2024-01-01 16:20:44 +00:00
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
|
|
|
def create_connection(db_file):
|
|
|
|
""" create a database connection to a SQLite database """
|
|
|
|
conn = None
|
|
|
|
try:
|
2024-01-01 17:52:44 +00:00
|
|
|
print("Opening Database file and ensuring table integrity")
|
2024-01-01 16:20:44 +00:00
|
|
|
conn = sqlite3.connect(db_file)
|
|
|
|
|
|
|
|
# Execute creation scripts
|
2024-01-01 16:25:58 +00:00
|
|
|
sql = open("scripts/create_tables.sql", "r");
|
2024-01-01 16:20:44 +00:00
|
|
|
conn.executescript(sql.read())
|
2024-01-01 17:52:44 +00:00
|
|
|
|
|
|
|
print("SQLite Version: " + sqlite3.version)
|
|
|
|
print("Table creation complete")
|
2024-01-01 20:19:57 +00:00
|
|
|
except sqlite3.Error as e:
|
2024-01-01 16:20:44 +00:00
|
|
|
print(e)
|
|
|
|
finally:
|
|
|
|
if conn:
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2024-01-01 16:25:58 +00:00
|
|
|
create_connection(r"./data/wmgzon.db")
|