python - How separate sql connection flask + pymssql -


i try create app flask. in stack use - ubuntu 16, nginx, uwsgi, flask. connection mssql db, use pymssql. app working, when try use 2 users different place, have same result. read, need use flask.g, it's not working me. below code connect db

def connect_db(user, password):    server = 'my_server'    database = 'my_db'    db = pymssql.connect(server=server, user=user, password=password,     database=database)    return db   def get_db(username, password):    u = username    p = password    if not hasattr(g, 'db'):       g.db = connect_db(u, p)    return g.db 

when login: send 2 parameters form, , add session, session add get_db , example - get_db(session['username'], session['password'])

if log session , @app.teardown_request , have different session each request

help please , sorry bad english


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -