You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import os.path
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
# Check if database exist
|
|
|
|
if os.path.exists('data/db/bazarr.db') == True:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# Get SQL script from file
|
|
|
|
fd = open('create_db.sql', 'r')
|
|
|
|
script = fd.read()
|
|
|
|
|
|
|
|
# Open database connection
|
|
|
|
db = sqlite3.connect('data/db/bazarr.db')
|
|
|
|
c = db.cursor()
|
|
|
|
|
|
|
|
# Execute script and commit change to database
|
|
|
|
c.executescript(script)
|
|
|
|
|
|
|
|
# Close database connection
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
# Close SQL script file
|
|
|
|
fd.close()
|