Skip to content

Instantly share code, notes, and snippets.

@aliwo
Created August 23, 2020 10:33
Show Gist options
  • Select an option

  • Save aliwo/e15546df1ad9ab3cd89ac19ba456f0cd to your computer and use it in GitHub Desktop.

Select an option

Save aliwo/e15546df1ad9ab3cd89ac19ba456f0cd to your computer and use it in GitHub Desktop.
from flask import Flask
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import time
app = Flask(__name__)
engine = create_engine('mysql+pymysql://root:22380476@localhost/pool?charset=UTF8MB4', pool_recycle=300)
SessionMaker = sessionmaker(bind=engine)
engine.execute('SELECT NOW();')
@app.route('/')
def index():
session = SessionMaker()
print(engine.pool.status())
time.sleep(0.3)
return 'Hello World'
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment