def __init__(self, name, folder=None, respect_venv=False):
if folder is None:
folder = SQLiteKVStore.DefaultFolder
#If we are relative to a virtual environment, place the registry into that virtual env
#Support both virtualenv and pythnon 3 venv
if respect_venv and hasattr(sys, 'real_prefix'):
folder = sys.prefix
elif respect_venv and hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
folder = sys.prefix
if not os.path.exists(folder):
os.makedirs(folder, 0755)
dbfile = os.path.join(folder, name)
self.connection = sqlite3.connect(dbfile)
self.cursor = self.connection.cursor()
self.file = dbfile
self._setup_table()
评论列表
文章目录