How can I keep SQLAlchemy DB connection alive for always?

5,597 views
Skip to first unread message

Eren Gölge

unread,
Oct 14, 2014, 3:27:11 PM10/14/14
to sqlal...@googlegroups.com
I a create a session with these following lines;


Base = declarative_base()

 engine
= create_engine('mysql://sentio_reader:ther...@sentiodb.cloudapp.net/sentio')

 
#engine = create_engine('mysql://erogol:ern88GOL!@sentioerogol.cloudapp.net/sentio_data')

# engine.echo = True
 metadata
= MetaData(bind=engine)

 metadata
.reflect(bind=engine)

 create_all_tables
()

 session
= create_session(bind=engine)

create_all_tables simply creates table objects based on the metadata for all the DB tables.

After I run this code, if I wait some times, functions like session.query() start to be unresponsive, I guess owing to some kind of time out. Is there any way to keep DB connection always alive in SQLAlchemy?

Robert Forkel

unread,
Oct 14, 2014, 3:29:42 PM10/14/14
to sqlal...@googlegroups.com
Pessimistic disconnect handling may be what you are looking for:

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages