Building the database using sql file
This commit is contained in:
@@ -4,6 +4,15 @@ class Database:
|
||||
def __init__(self, database_file):
|
||||
self.db = sqlite3.connect(database_file)
|
||||
|
||||
def build_database(self, sql_file_path):
|
||||
sql_script_string = ''
|
||||
with open(sql_file_path, 'r') as sql_file:
|
||||
sql_script_string = sql_file.read()
|
||||
|
||||
cursor = self.db.cursor()
|
||||
cursor.executescript(sql_script_string)
|
||||
self.db.commit()
|
||||
|
||||
def select(self, index):
|
||||
# Query the database for the specified index
|
||||
cursor = self.db.cursor()
|
||||
|
||||
Reference in New Issue
Block a user