in purchase-function/src/inventory.py [0:0]
def _initialize_database(self):
conn = self._get_db_connection()
try:
cursor = conn.cursor()
#Creating stock tables
cursor.execute('''
CREATE TABLE IF NOT EXISTS snapshots (
id INTEGER PRIMARY KEY AUTOINCREMENT,
related_order_id TEXT NULL,
items text NOT NULL,
[timestamp] TIMESTAMP
);
''')
#Creating product table
cursor.execute('''
CREATE TABLE IF NOT EXISTS product (
id INTEGER PRIMARY KEY ,
product_name TEXT NULL,
price INTEGER NULL
);
''')
conn.commit()
conn.close()
except sqlite3.Error as e:
logger.info("conn is closed due to db exception")
conn.close()