Clean up db.py

This commit is contained in:
Jacob Hinkle 2022-09-20 12:08:48 -04:00
parent 3ae90db4a8
commit 3a99a14a0a
3 changed files with 8 additions and 20 deletions

View File

@ -1,26 +1,9 @@
import sqlite3
from . import db
from . import store
from .version import __version__
# Calling code will build up a large DAG then at the very last step, call
# nancy.save_data(). Only at that point will we determine where to save the
# data by asking the user for an output dir. However, we need a database
# initialized in order to build up the DAG in the first place, so here we
# initialize an in-memory database to use until we have an output directory.
_conn = db.init(":memory:")
def persist_db(dbpath):
global _conn
dst_conn = sqlite3.connect(dbpath)
_conn.backup(dst_conn)
_conn.close()
_conn = dst_conn
def save_data(
destination_mapping,
desc=f"Provenance-tracking with nancy v{__version__}",

View File

@ -3,7 +3,9 @@ import os
import sqlite3
schema_version = 2
# This matches the recorded user_version in any nancy.db initialized in this
# process.
schema_version = 0
def init(path):

View File

@ -1 +1,4 @@
__version__ = "0.0.1pre"
from .db import schema_version
__version__ = "0.1.0"