Improve sqlite3 connection creation

This commit is contained in:
Marty Oehme 2021-12-06 16:37:04 +01:00
parent 76b2dd4408
commit 2dbc6945a2
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -2,23 +2,19 @@ import sqlite3
def create_database(name):
return sqlite3.connect(name)
"""create a database connection to the SQLite database
specified by db_file
:param db_file: database file
:return: Connection object or None
"""
conn = None
try:
conn = sqlite3.connect(name)
return conn
except sqlite3.Error as e:
print(e)
# TODO better way to do the above
# def create_connection(db_file):
# """create a database connection to the SQLite database
# specified by db_file
# :param db_file: database file
# :return: Connection object or None
# """
# conn = None
# try:
# conn = sqlite3.connect(db_file)
# return conn
# except Error as e:
# print(e)
# return conn
return conn
def create_tables(db):