[sqlalchemy] sqlalchemy how to enlarge current using connections

2014-04-08 Thread Ni Wesley
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

Re: [sqlalchemy] sqlalchemy how to enlarge current using connections

2014-04-08 Thread Ni Wesley
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 javascript: 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

Re: [sqlalchemy] sqlalchemy how to enlarge current using connections

2014-04-08 Thread Ni Wesley
and dbupdate which are called by other modules. Based on the above code, mostly I only see 4-5 processlist from mysql server side... That's means, I haven't reached the bottleneck of mysql server itself... 在 2014年4月8日星期二UTC+8下午9时52分58秒,Michael Bayer写道: On Apr 8, 2014, at 8:55 AM, Ni Wesley nis

Re: [sqlalchemy] sqlalchemy how to enlarge current using connections

2014-04-08 Thread Ni Wesley
100 tasks into it. [wni] I will try creating new engine for each sub process later :-) On Apr 8, 2014, at 10:21 AM, Ni Wesley nis...@gmail.com javascript: wrote: The above procedure can be performed in a shorthand way by using the execute()http://docs.sqlalchemy.org/en/rel_0_9/core

[sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
Hi all, Today I get an error as title. I use sqlalchemy + mysql. Here is my code snippet: def dbquery(_table,whereclause): try: #_table=Table(tablename, metadata, autoload=True) #_table = tables[tablename] i=_table.select().where(whereclause) if

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
like mysql-connector-python just to see what’s different. On Mar 27, 2014, at 7:41 AM, Ni Wesley nis...@gmail.com javascript: wrote: Hi all, Today I get an error as title. I use sqlalchemy + mysql. Here is my code snippet: def dbquery(_table,whereclause): try

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
like mysql-connector-python just to see what’s different. On Mar 27, 2014, at 7:41 AM, Ni Wesley nis...@gmail.com javascript: wrote: Hi all, Today I get an error as title. I use sqlalchemy + mysql. Here is my code snippet: def dbquery(_table,whereclause): try

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
into a bad state. There are likely patterns in how you’re calling it that lead it to have this issue but you might try a different DBAPI like mysql-connector-python just to see what’s different. On Mar 27, 2014, at 7:41 AM, Ni Wesley nis...@gmail.com wrote: Hi all, Today I get an error

[sqlalchemy] MySQL server has gone away

2014-03-18 Thread Ni Wesley
Hi all, I hit a problem when using sqlalchemy operates mysql. Engine.execute hangs about 5 mins... and then, get error: 'MySQL server has gone away' or 'Lost connection to MySQL server during query'. Actually, when operation hangs, I login mysql server is OK. Why this happened? Or how to

[sqlalchemy] Re: MySQL server has gone away

2014-03-18 Thread Ni Wesley
I tried all you said. Here is my code: engine = create_engine(db_url, pool_size=100,max_overflow=150,echo=engine_echo,pool_recycle=3600) And, in the beginning, I googled a lot and add this: def _ping_db(): #session.execute('show variables') try: session.execute('select 1')

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-15 Thread Ni Wesley
operation and throw into a process pool which only handle db operation. 在 2014年3月16日星期日UTC+8上午4时14分50秒,Michael Bayer写道: On Mar 14, 2014, at 9:18 PM, Ni Wesley nis...@gmail.com javascript: wrote: Seems sqlalchemy engine pool uses thread, eh? SQLAlchemy doesn’t spawn any threads, it only

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-14 Thread Ni Wesley
Yes, actually, that's the pattern I used from the beginning, i.e. for every request(actually tcp server connection request), create a session, do db operation, commit, and close. But it's too slow, for 1000 connections requests, it takes more than 40 seconds, so , just yesterday, when using

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-13 Thread Ni Wesley
sqls. 在 2014年3月13日星期四UTC+8下午8时59分34秒,Michael Bayer写道: On Mar 13, 2014, at 12:10 AM, Ni Wesley nis...@gmail.com javascript: wrote: We can see that, from the start point to end point, it takes 50 ms, including 40ms for engine commit. For 1000 entries, it takes 40 seconds, here I

[sqlalchemy] Re: sql expression performance is bad ?

2014-03-13 Thread Ni Wesley
1. Yeah, I do have index on app_key and device_token 2. I realized the issue with how I use sessions every request, so , later, instead of sessions, I directly call engine.execute where engine is initiated just once from another file. Seems no improvement compared to session... 在

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-13 Thread Ni Wesley
procedures and call the procedures , instead of core sqls. 在 2014年3月13日星期四UTC+8下午8时59分34秒,Michael Bayer写道: On Mar 13, 2014, at 12:10 AM, Ni Wesley nis...@gmail.com wrote: We can see that, from the start point to end point, it takes 50 ms, including 40ms for engine commit. For 1000

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-13 Thread Ni Wesley
procedures and call the procedures , instead of core sqls. 在 2014年3月13日星期四UTC+8下午8时59分34秒,Michael Bayer写道: On Mar 13, 2014, at 12:10 AM, Ni Wesley nis...@gmail.com wrote: We can see that, from the start point to end point, it takes 50 ms, including 40ms for engine commit. For 1000

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-13 Thread Ni Wesley
Actually I have a question here, I see the main time consuming is commit.. But how to control the time to commit. Because I don't know when request will come and how many requests will come, so seems my current code is to commit every engine.execute 在 2014年3月14日星期五UTC+8上午2时14分43秒,Jonathan

[sqlalchemy] sqlalchemy only has 1 or 2 tcp connections to mysql server

2014-03-13 Thread Ni Wesley
Hi all, I hit a problem that cannot use the connection pool effectively. engine = create_engine(db_url,pool_size=50,max_overflow=60, echo=engine_echo,pool_recycle=3600) from sqlalchemy.sql.expression import text, bindparam from sqlalchemy.sql import select,insert, delete, update from

Re: [sqlalchemy] sqlalchemy only has 1 or 2 tcp connections to mysql server

2014-03-13 Thread Ni Wesley
No, I don't use gevent anymore, everything goes from engine, you can see I have a direct_engine=True to control 在 2014年3月14日星期五UTC+8下午12时22分09秒,Michael Bayer写道: On Mar 13, 2014, at 11:51 PM, Ni Wesley nis...@gmail.com javascript: wrote: Hi all, I hit a problem that cannot use

[sqlalchemy] sql expression performance is bad ?

2014-03-12 Thread Ni Wesley
Hi guys, I hit a problem when using sqlalchemy operating mysql. First, let me clarify my code frames. I have a web service to receive http requests, then, it send task to a tcp server via zeromq pull/push mode, tcp server pull and do some push work to cell phone. I hit a problem that, tcp

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-12 Thread Ni Wesley
. Thanks. Wesley 在 2014年3月12日星期三UTC+8下午9时35分08秒,Michael Bayer写道: On Mar 12, 2014, at 8:32 AM, Ni Wesley nis...@gmail.com javascript: wrote: Hi guys, I hit a problem when using sqlalchemy operating mysql. First, let me clarify my code frames. I have a web service

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-12 Thread Ni Wesley
Just have a try. Move all operations upon session directly to engine.execute. Almost the same performance. How to improve? :-( 在 2014年3月12日星期三UTC+8下午9时35分08秒,Michael Bayer写道: On Mar 12, 2014, at 8:32 AM, Ni Wesley nis...@gmail.com javascript: wrote: Hi guys, I hit a problem

Re: [sqlalchemy] sql expression performance is bad ?

2014-03-12 Thread Ni Wesley
...@gmail.com, could I invite you to my friend list? 在 2014年3月13日星期四UTC+8上午10时18分01秒,Michael Bayer写道: hows your SQL debug output and your profiling going? On Mar 12, 2014, at 9:56 PM, Ni Wesley nis...@gmail.com javascript: wrote: Just have a try. Move all operations upon session

[sqlalchemy] Re: sql expression performance is bad ?

2014-03-12 Thread Ni Wesley
, via command watch -n 1 netstat -anpto|grep dbserver_ip|wc -l, I find the spike value is just 26, actually, I gave 0 to engine pool_size, why it takes only 26? Is this related 在 2014年3月12日星期三UTC+8下午8时32分53秒,Ni Wesley写道: Hi guys, I hit a problem when using sqlalchemy operating mysql

[sqlalchemy] Session commit block?

2014-03-01 Thread Ni Wesley
Hi all, I hit a problem these day that sqlalchemy session execute hangs some time. And if one db operation hangs, all the following operations are blocked... Here is exception snippet: ERROR:tornado.application:Uncaught exception, closing connection. Traceback (most recent call last): File

Re: [sqlalchemy] Session commit block?

2014-03-01 Thread Ni Wesley
Here is my code: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker,scoped_session from sqlalchemy.schema import MetaData engine = create_engine(db_url, echo=engine_echo,pool_recycle=300) session = scoped_session(sessionmaker(bind=engine)) So, for code blocks that need

Re: [sqlalchemy] Sqlalchemy ORM operates on database not created from sqlalchemy

2014-01-22 Thread Ni Wesley
I mean sqlalchemy ORM, that is, use python class mapping to database table. I know sqlalchemy core expression does work, this guy doesn't care how database is created. Wesley 2014年1月22日 下午7:04于 Simon King si...@simonking.org.uk写道: On Wed, Jan 22, 2014 at 3:41 AM, Ni Wesley nisp...@gmail.com

[sqlalchemy] Sqlalchemy ORM operates on database not created from sqlalchemy

2014-01-21 Thread Ni Wesley
Hi guys, I have a question here. Just as the title, I mean, for example: I am using mysql as the database engine. Now, I use sqlalchemy ORM to map python class to database table. My question is here: Actually, there are specified teams to do the database design and tables creation work.

[sqlalchemy] Sqlalchemy ORM operates on database not created from sqlalchemy

2014-01-21 Thread Ni Wesley
Hi guys, I have a question here. Just as the title, I mean, for example: I am using mysql as the database engine. Now, I use sqlalchemy ORM to map python class to database table. My question is here: Actually, there are specified teams to do the database design and tables creation work.

[sqlalchemy] Re: Mysql server has gone away

2014-01-13 Thread Ni Wesley
I just find a solution that try to ping database server by select 1 every give time. Thanks all you guys. -- 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] Mysql server has gone away

2014-01-12 Thread Ni Wesley
Hi all, I hit a problem when use sqlalchemy with mysql. I found the problem is mysql's auto close to nonactive connection over 8 hours. And , I googled a lot and find pool_recycle option for create_engine. But seems does not work. Here is my code: engine = create_engine(db_url,