Created
March 17, 2022 03:18
-
-
Save wannadrunk/dc139ab5cf907f07362306cf57d805f9 to your computer and use it in GitHub Desktop.
SAMPLE SQLAlchemy connect to existing DB/Tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy import create_engine, MetaData, Table | |
# Using SQLAlchemy reflection example | |
engine = create_engine('connectionstringhere') | |
table1meta = MetaData(engine) | |
table1 = Table('Table_I_Want_to_Interact', table1meta, autoload=True) | |
DBSession = sessionmaker(bind=engine) | |
session = DBSession() | |
results = session.query(table1).filter(table1.columns.TimeStamp>="2019-02-26 18:00:00.000") | |
results.all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment