def __init__(self, url, result_table="results", complementary_table="complementary", space_table="space"):
super(SQLiteConnection, self).__init__()
if url.endswith("/"):
raise RuntimeError("Empty database name {}".format(url))
if url.endswith((" ", "\t")):
raise RuntimeError("Database name ends with space {}".format(url))
if not url.startswith("sqlite://"):
raise RuntimeError("Missing 'sqlite:///' at the begin of url".format(url))
if url == "sqlite://" or url == "sqlite:///:memory:":
raise RuntimeError("Cannot use memory database as it exists only for the time of the connection")
match = re.search("sqlite:///(.*)", url)
if match is not None:
db_path = match.group(1)
else:
raise RuntimeError("Cannot find sqlite db path in {}".format(url))
self.url = url
self.result_table_name = result_table
self.complementary_table_name = complementary_table
self.space_table_name = space_table
self._lock = filelock.FileLock("{}.lock".format(db_path))
self.hold_lock = False
# with self.lock():
# db = dataset.connect(self.url)
# # Initialize a result table and ensure float for loss
# results = db[self.result_table_name]
# results.create_column("_loss", sqlalchemy.Float)
评论列表
文章目录