diff --git a/habitmove/schema.py b/habitmove/schema.py index 0c3d56c..e5e8404 100644 --- a/habitmove/schema.py +++ b/habitmove/schema.py @@ -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):