"""
Functions to setup a real and sample database
"""
# General imports
from peewee import *
from datetime import datetime as DT
import logging
from passlib.handlers.pbkdf2 import pbkdf2_sha256

# Internal imports
from models import db
from models.models import *

# Function to generate the tables in database
def create_schema():
    """ Generates the tables in the database """
    logging.info("Creating DB schema")
    with db:
        db.create_tables([User, KnownFace, Attendance])
        logging.info("DB schema created.")

# Function to populate database with sample data
def populate_sample_data():
    """ Populates the database with sample data """
    with db:
        u = User(login_id="test", password=<PASSWORD>("<PASSWORD>"), role="ST",
        email="<EMAIL>", first_name="TEST", last_name="USER", inst_id="CSB1000")
        u.save()

        u = User(login_id="admin", password=<PASSWORD>("<PASSWORD>"), role="SU",
        email="<EMAIL>", first_name="ADMIN", last_name="USER", inst_id="CSB1001")
        u.save()

# Function to setup demo database
def setup_demo_db():
    """ Sets up a demo database """
    create_schema()
    populate_sample_data()
"""
Functions to setup a real and sample database
"""
# General imports
from peewee import *
from datetime import datetime as DT
import logging
from passlib.handlers.pbkdf2 import pbkdf2_sha256

# Internal imports
from models import db
from models.models import *

# Function to generate the tables in database
def create_schema():
    """ Generates the tables in the database """
    logging.info("Creating DB schema")
    with db:
        db.create_tables([User, KnownFace, Attendance])
        logging.info("DB schema created.")

# Function to populate database with sample data
def populate_sample_data():
    """ Populates the database with sample data """
    with db:
        u = User(login_id="test", password=<PASSWORD>("<PASSWORD>"), role="ST",
        email="<EMAIL>", first_name="TEST", last_name="USER", inst_id="CSB1000")
        u.save()

        u = User(login_id="admin", password=<PASSWORD>("<PASSWORD>"), role="SU",
        email="<EMAIL>", first_name="ADMIN", last_name="USER", inst_id="CSB1001")
        u.save()

# Function to setup demo database
def setup_demo_db():
    """ Sets up a demo database """
    create_schema()
    populate_sample_data()
Functions to setup a real and sample database # General imports # Internal imports # Function to generate the tables in database Generates the tables in the database # Function to populate database with sample data Populates the database with sample data # Function to setup demo database Sets up a demo database