Last active
September 8, 2023 11:03
-
-
Save aeruo/d4994a920f904cf9fc601ab3d958bce7 to your computer and use it in GitHub Desktop.
Executes sql from schema.sql file into database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
def dbinit(): | |
connection = sqlite3.connect('database.db') | |
with open('schema.sql') as f: | |
connection.executescript(f.read()) | |
cur = connection.cursor() | |
connection.commit() | |
connection.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment