Last active
February 26, 2023 12:58
-
-
Save Tarliton/f4da871b13be8cb73c10f6ac1dae91e8 to your computer and use it in GitHub Desktop.
Quick sqlalchemy reflect whole database
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 import create_engine | |
from sqlalchemy.ext.automap import automap_base | |
from sqlalchemy.orm import sessionmaker | |
url = 'mysql://<user>:<password>@<ip>:<port>/<name>' | |
engine = create_engine(url, echo=True) | |
Base = automap_base() | |
Base.prepare(autoload_with=engine) | |
Session = sessionmaker(bind=engine) | |
session = Session() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment