[sqlalchemy] The right way to use gevent with sqlalchemy

2017-07-14 Thread Tony Wang
I simplify a complex system of gevent with sqlachemy to a simple demo code . Before using of sqlachemy, pymysql is my best choice for communication between MySql and gevent because of its easy and direct usage. But now I fe

Re: [sqlalchemy] Re: Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread josip povreslo
Thanks! On Saturday, July 15, 2017 at 12:08:19 AM UTC+2, Mike Bayer wrote: > > I've set up > https://bitbucket.org/zzzeek/sqlalchemy/issues/4028/move-cant-connect-handling-outside-of > > to deal with the misleading "pool.Empty" error for 1.2, though that is > not the problem you're having here

Re: [sqlalchemy] Re: Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread josip povreslo
Thanks Mike! Point valid, it's mysqlclient==1.3.9, we don't have MySQL-Python installed, inherited the system so I assumed it's mysql-connector from some reason, nevertheless. Hmmm, I was afraid that's the actual case (connection error). We were checking the connection limits and that's not t

Re: [sqlalchemy] Re: Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread Mike Bayer
I've set up https://bitbucket.org/zzzeek/sqlalchemy/issues/4028/move-cant-connect-handling-outside-of to deal with the misleading "pool.Empty" error for 1.2, though that is not the problem you're having here. On Fri, Jul 14, 2017 at 5:57 PM, Mike Bayer wrote: > that "mysqldb" URL is not mysql-co

Re: [sqlalchemy] Re: Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread Mike Bayer
that "mysqldb" URL is not mysql-connector - it's MySQL-Python (old and unmaintained) or mysqlclient (much better, if you have it installed and not conflicting w/ MySQL-Python). You'd need to specify "mysql+mysqlconnector://" to use that DBAPI, but also I'd recommend trying "mysql+pymysql://" to s

[sqlalchemy] Re: Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread josip povreslo
In addition to the previous email, what I do is the following: When request comes in: self.mysql_engine = create_engine('mysql+mysqldb://{}:{}@{}/{}'.format(self.db_params['dbuser'], self.db_params['dbpass'], self.db_params['db_hosts'][db_host_index], self.db_params['dbname']), pool_recycle=360

[sqlalchemy] Python 3.5 mysql-connector==2.1.6 SQLAlchemy==1.1.11 queue Empty

2017-07-14 Thread josip povreslo
Hello, As mentioned in the subject, we have the following packages installed: - Python 3.5 - mysql-connector==2.1.6 - - SQLAlchemy==1.1.11 Our service is working until we get a bit more traffic (40 - 50 req/min), although I'm still not 100% if it's a pattern, however, then we get

Re: [sqlalchemy] session.add() neglecting some of my objects to be added

2017-07-14 Thread Mike Bayer
On Fri, Jul 14, 2017 at 1:24 AM, David Laredo Razo wrote: this code is the problem: > > new_object = copy.copy(reading) copy() will copy the _sa_instance_state and prevent the session from tracking the object correctly. Correct pattern should be: new_object = ThermafuserReading(None, compone

Re: [sqlalchemy] Re: inline polymorphic_load for single table inheritance

2017-07-14 Thread Mike Bayer
On Fri, Jul 14, 2017 at 10:40 AM, Shane Carey wrote: > Okay, I understand that. My example isnt actually the best for the question > I am asking. > > Say I have three subclasses ChildOne, ChildTwo, ChildThree > > is there a way to query for ChildOne and ChildTwo in one query, or do I need > to fil

[sqlalchemy] Re: inline polymorphic_load for single table inheritance

2017-07-14 Thread Shane Carey
Okay, I understand that. My example isnt actually the best for the question I am asking. Say I have three subclasses ChildOne, ChildTwo, ChildThree is there a way to query for ChildOne and ChildTwo in one query, or do I need to filter on the discriminator? something like session.query(ChildOne