bazarr/init_db.py
Louis Vézina 78d132bd7c Revert "Test"
This reverts commit 14d1e7b345.
2017-10-21 20:18:27 -04:00

24 lines
628 B
Python

import os
import sqlite3
# Check if database exist
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
pass
else:
# Get SQL script from file
fd = open(os.path.join(os.path.dirname(__file__), 'create_db.sql'), 'r')
script = fd.read()
# Open database connection
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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()