Skip to content

Commit

Permalink
Added create DB function in Cache class
Browse files Browse the repository at this point in the history
  • Loading branch information
npalacioescat committed May 27, 2024
1 parent 210b873 commit 4079307
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions cache_manager/_cache.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import sqlite3
import os
import sqlite3

__all__ = [
'Cache',
]


class Cache:
"""
The Cache class.
"""

def __init__(self, path: str):
"""
This is not empty.
"""

self._set_path(path)


def __del__(self):

self.con.close()

self.con.close()

def _set_path(self, path: str):

Expand All @@ -26,3 +34,32 @@ def _open_sqlite(self):

self.con = sqlite3.connect(self.path)
self.cur = self.con.cursor()

def _create_schema(self):

self._open_sqlite()
self.cur.execute('''
CREATE TABLE IF NOT EXISTS
main (
id INT PRIMARY KEY,
item_id VARCHAR,
version_id VARCHAR,
version INT,
status INT,
file_name VARCHAR,
label VARCHAR,
date DATE,
extension VARCHAR
)
''')

for typ in ['varchar, int, date']:
self.cur.execute(
'''
CREATE TABLE IF NOT EXISTS
attr_{} (
version_id VARCHAR FOREIGN KEY,
value {}
)
'''.format(typ, typ.upper()),
)

0 comments on commit 4079307

Please sign in to comment.