On Apr 8, 2014, at 8:55 AM, Ni Wesley <nisp...@gmail.com> wrote: > For me, I just use engine.execute most of the time, any problem with this? > > Or if I use session or connect, do I need to close the session or connection > everytime? otherwise, it will trigger the pool size limit error as the > connection is increasing, right?
if you use sessions or a Connection object then yes you need to make sure those are closed when you’re done. The docs at http://docs.sqlalchemy.org/en/rel_0_9/core/connections.html have background on the difference between engine.execute and connection.execute. > > > 在 2014年4月8日星期二UTC+8下午8时49分16秒,Michael Bayer写道: > To make more connections, call connect(), and/or use more session objects. > Each session uses one connection. > > If you see three connections, that means your script has only worked with > three connections at once, such as, you opened three Session objects > concurrently. > > Sqlalchemy does not initiate any concurrent operations on its own. > > > Sent from my iPhone > > On Apr 8, 2014, at 5:03 AM, Ni Wesley <nis...@gmail.com> wrote: > >> Hi all, >> I have a question here. >> >> Here is my db init code snippet: >> >> engine = create_engine(db_url, >> pool_size=100,max_overflow=150,echo=engine_echo,pool_recycle=3600) >> session = scoped_session(sessionmaker(bind=engine)) >> metadata = MetaData(bind=engine) >> >> Then, I use engine to do update/insert operations. >> >> There is no problem here, then I find during the performance test that, it's >> too slow to insert/update mysql server. >> When my script running, on mysql server, use mysql 'show processlist;' >> command, I see only 2 or 3 active connections kept. >> >> Then,within my script, I use multiprocessing.pool(defaults to cpu core size, >> which is 4 for me) to do mysql insert/update operations. >> >> Finally, I see 4 or 5 connections kept from mysql server. >> >> So, seems db operation is bottleneck because I cannot use more connections >> yet. >> >> How to push the conncurrent connections up? I am sure script generating db >> tasks are fast enough. >> >> Thanks. >> Wesley >> >> >> -- >> 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. > > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.