Skip to content

Commit

Permalink
fix(db): add _about table
Browse files Browse the repository at this point in the history
  • Loading branch information
engisalor committed Dec 1, 2022
1 parent 526aacc commit e437afd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions corpusama/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import sqlite3 as sql

from corpusama._version import __version__
from corpusama.util import convert

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -46,6 +47,7 @@ def get_tables(self):
# get tables if db not empty
if [x[0] for x in res.fetchall()]:
queries = [
"SELECT * FROM _about",
"SELECT * FROM _log",
"SELECT * FROM _pdf",
"SELECT * FROM _raw",
Expand Down Expand Up @@ -110,6 +112,16 @@ def _add_missing_columns(self, df, table):
df[x] = None
return df

def set_about(self):
"""Records metadata about a database."""

query = """CREATE TABLE IF NOT EXISTS _about
('key' TEXT PRIMARY KEY, 'value' TEXT)"""
self.c.execute(query)
values = ("version", __version__)
self.c.execute("INSERT OR REPLACE INTO _about VALUES (?,?)", values)
self.conn.commit()

def __repr__(self):
return ""

Expand All @@ -126,3 +138,4 @@ def __init__(
self.open_db()
self.get_schema()
self.get_tables()
self.set_about()

0 comments on commit e437afd

Please sign in to comment.