def ft_db_init_conn(path=None): """Meta function to init database connection. """ ret_value = None if ft_config_get('FT_DB') == 'SQLITE': ret_value = ft_db_init_conn_sqlite(path=path) else: # Unsupported Database Type raise Exception('ERR_DB_NOT_IMPLEMENTED') return ret_value
def ft_db_init_conn_sqlite(path=None): """Connect to sqlite database. return a sqlite3.conn object. """ if path is not None: db_file = path else: db_file = ft_config_get('FT_DB_FILE') assert db_file is not None and db_file != '' conn = sqlite3.connect(db_file) assert conn is not None return conn