Skip to content

Instantly share code, notes, and snippets.

@aeruo
Last active September 8, 2023 11:03
Show Gist options
  • Save aeruo/d4994a920f904cf9fc601ab3d958bce7 to your computer and use it in GitHub Desktop.
Save aeruo/d4994a920f904cf9fc601ab3d958bce7 to your computer and use it in GitHub Desktop.
Executes sql from schema.sql file into database
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