import os
from typing import List, Optional

from dotenv import load_dotenv
from sqlalchemy import (Boolean, Column, ForeignKey, Integer, MetaData, String,
                        Table, create_engine, text, insert, select)
from sqlalchemy.orm import (DeclarativeBase, Mapped, Session, mapped_column,
                            relationship)

load_dotenv()

DB_PASS = os.getenv("DOCKER_POSTGRES_PASS")

# Create engine for connecting to postgres test db
DB_ENGINE = create_engine(
    f'postgresql+psycopg2://postgres:{DB_PASS}@localhost:5432/postgres')

METADATA_OBJECT = MetaData()

# Declaring user table
CORE_USER_TABLE = Table(
    "user_account",
    METADATA_OBJECT,
    Column("id", Integer, primary_key=True),
    Column("name", String(30)),
    Column("fullname", String),
)

# Declaring address table
CORE_ADDRESS_TABLE = Table(
    "address",
    METADATA_OBJECT,
    Column("id", Integer, primary_key=True),
    Column("user_id", ForeignKey("user_account.id"), nullable=False),
    Column("email_address", String, nullable=False)
)
