""" database dependencies to support sqliteDB examples """

from __init__ import app, db
from sqlalchemy.exc import IntegrityError
from werkzeug.security import generate_password_hash, check_password_hash


""" Key additions to User Class for Schema definition """

# Define the User class to manage actions in the 'users' table
# -- Object Relational Mapping (ORM) is the key concept of SQLAlchemy
# -- a.) db.Model is like an inner layer of the onion in ORM
# -- b.) User represents data we want to store, something that is built on db.Model
# -- c.) SQLAlchemy ORM is layer on top of SQLAlchemy Core, then SQLAlchemy engine, SQL
class User(db.Model):
    __tablename__ = 'users'  # table name is plural, class name is singular

    # Define the User schema with "vars" from object
    id = db.Column(db.Integer, primary_key=True)
    _name = db.Column(db.String(255), unique=False, nullable=False)
    _uid = db.Column(db.String(255), unique=True, nullable=False)
    _password = db.Column(db.String(255), unique=False, nullable=False)
    _dob = db.Column(db.Date)

    # Defines a relationship between User record and Notes table, one-to-many (one user to many notes)
    posts = db.relationship("Post", cascade='all, delete', backref='users', lazy=True)

    # constructor of a User object, initializes the instance variables within object (self)
    def __init__(self, name, uid, password="123qwerty", dob=date.today()):
        self._name = name    # variables with self prefix become part of the object, 
        self._uid = uid
        self.set_password(password)
        self._dob = dob
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/Users/nathancapule/vscode/CSPFastpages/CSPFastpages/_notebooks/2023-01-18-DatabaseTable.ipynb Cell 2 in <cell line: 3>()
      <a href='vscode-notebook-cell:/Users/nathancapule/vscode/CSPFastpages/CSPFastpages/_notebooks/2023-01-18-DatabaseTable.ipynb#W2sZmlsZQ%3D%3D?line=0'>1</a> """ database dependencies to support sqliteDB examples """
----> <a href='vscode-notebook-cell:/Users/nathancapule/vscode/CSPFastpages/CSPFastpages/_notebooks/2023-01-18-DatabaseTable.ipynb#W2sZmlsZQ%3D%3D?line=2'>3</a> from __init__ import app, db
      <a href='vscode-notebook-cell:/Users/nathancapule/vscode/CSPFastpages/CSPFastpages/_notebooks/2023-01-18-DatabaseTable.ipynb#W2sZmlsZQ%3D%3D?line=3'>4</a> from sqlalchemy.exc import IntegrityError
      <a href='vscode-notebook-cell:/Users/nathancapule/vscode/CSPFastpages/CSPFastpages/_notebooks/2023-01-18-DatabaseTable.ipynb#W2sZmlsZQ%3D%3D?line=4'>5</a> from werkzeug.security import generate_password_hash, check_password_hash

ModuleNotFoundError: No module named '__init__'