-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorm_base.py
More file actions
16 lines (13 loc) · 866 Bytes
/
orm_base.py
File metadata and controls
16 lines (13 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import MetaData
from db_connection import userID
# Note - The "connect string" shown in db_connection only goes so far as to specify the
# database name, which defaults to 'postgres' if you just hit enter. in this case.
# Be sure to create the proper schema in the postgresql database BEFORE trying to run
# this code, SQLAlchemy will not do that for you.
# If nothing is entered when input prompts the user for the schema, then the or gets a
# null string for the first argument which evaluates to false, which means that the
# boolean expression takes the right-hand argument as its output and passes that in to the
# MetaData constructor.
Base = declarative_base(metadata=MetaData(schema=(input(f'Schema name [{userID}]-->') or userID)))
metadata = Base.metadata