Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created March 17, 2020 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/b0bbdf9d0a1f194727152a85a3e287c7 to your computer and use it in GitHub Desktop.
Save cuongld2/b0bbdf9d0a1f194727152a85a3e287c7 to your computer and use it in GitHub Desktop.
Access mysql db
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = "mysql+mysqlconnector://root:cuong1990@localhost:3306/restapi"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment