Exemple #1
0
# How to create the database with all the relevant tables using sqlite3 and python taken from this tutorial:
# https://www.sqlitetutorial.net/sqlite-python/create-tables/

import sqlite3
from sqlite3 import Error

# get file path for eHealth directory and add it to sys.path
# import my modules
# delete file path for eHealth directory from sys.path
import get_path_utilities as path
current = path.get_current_dir()
eHealth_dir = path.getDir(current, 2)
path.insert_dir(eHealth_dir)
from src.database import db_utilities as dbu
from src.database import connect
path.delete_dir()


def create_table(conn, create_table_sql):
    """ create a table from the create_table_sql statement
    :param conn: Connection object
    :param create_table_sql: a CREATE TABLE statement
    """
    try:
        c = conn.cursor()
        c.execute(create_table_sql)
    except Error as e:
        print(e)


def create_admin(conn, admin):
def db_path(num):
    current = get_path.get_current_dir()
    package_dir = get_path.getDir(current, num)
    database_path = os.path.join(package_dir, 'data/eHealth.db')
    return (database_path)