[sqlalchemy] Joined/Eager loading into a non-relationship

2016-06-14 Thread Nick Whyte
Hey, I'm working on a more complex problem with the ORM functionality of SQLA. I have a reasonably simple relationship, ie, class A(Base): id = sa.Column(sa.Integer(), primary_key=True) b_collection = sa.orm.relationship('B') class B(Base): id = sa.Column(sa.Integer(),

Re: [sqlalchemy] MySQL server has gone away

2016-06-14 Thread Dev Mukherjee
On Wed, Jun 15, 2016 at 7:27 AM, Jeffrey Yunes wrote: > Hi all, > After successful queries and a 10 minute wait, I'm getting the popular > "MySQL server has gone away." I have a single-threaded app and my > pool_recycle is way less than my wait_timeout. > > Do I need to create a

Re: [sqlalchemy] MySQL server has gone away

2016-06-14 Thread Jeffrey Yunes
Hi Mike and all, So, mostly good news. First to answer your question, I'm not aware of any long standing queries. During the 10 minutes between queries, `SHOW PROCESSLIST` indicates there are no queries running (two sleeping). The only remotely suspicious thing in the query log is a `BEGIN

Re: [sqlalchemy] MySQL server has gone away

2016-06-14 Thread Mike Bayer
not really. Are you leaving a long-running transaction open and not closing it (or rolling back / committing) ? On 06/14/2016 07:06 PM, Jeffrey Yunes wrote: Sorry, no dice! I switched to pymysql. I'm connecting via 127.0.0.1, so I don't think it's a network issue. Pretty much the same

Re: [sqlalchemy] MySQL server has gone away

2016-06-14 Thread Jeffrey Yunes
Sorry, no dice! I switched to pymysql. I'm connecting via 127.0.0.1, so I don't think it's a network issue. Pretty much the same error... Any thoughts? 2016-06-14 15:45:20,889 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'sql_mode' ... 2016-06-14 15:56:42,530 INFO

Re: [sqlalchemy] MySQL server has gone away

2016-06-14 Thread Mike Bayer
Well I'd get off of OurSQL to start with since it is unmaintained for years now. The "gone away" error doesn't always mean the connection was actually dropped, in some old school situations it just means the client got out of sync with the MySQL protocol. ( waits ) still broken?

[sqlalchemy] MySQL server has gone away

2016-06-14 Thread Jeffrey Yunes
Hi all, After successful queries and a 10 minute wait, I'm getting the popular "MySQL server has gone away." I have a single-threaded app and my pool_recycle is way less than my wait_timeout. Do I need to create a new session after the pool recycles? I'd love to know which part of the docs

Re: [sqlalchemy] Question about eagerloading and depth of inheritance with respect to polymorphic mappings

2016-06-14 Thread Mike Bayer
On 06/14/2016 11:28 AM, Ken Linehan wrote: Hello, I'm working with a class inheritance structure which can be illustrated by this example: | class Entity(object): def __init__(self, entity_type=EntityTypeEntity, id=None): self.entity_type = entity_type self.id = id

[sqlalchemy] Question about eagerloading and depth of inheritance with respect to polymorphic mappings

2016-06-14 Thread Ken Linehan
Hello, I'm working with a class inheritance structure which can be illustrated by this example: class Entity(object): def __init__(self, entity_type=EntityTypeEntity, id=None): self.entity_type = entity_type self.id = id class Person(Entity): def __init__(self,

Re: [sqlalchemy] nullable dates

2016-06-14 Thread Marco Correia
Thanks. It turned out that I was sending an empty string for date (instead of null), and that was being translated as -00-00 (your script works except I was using mysql+pysql). I didn't saw it since google developer tools logs, wrongly, that a null is being sent. Thanks a lot for the help.

Re: [sqlalchemy] How to make escaped column names in sqlalchemy

2016-06-14 Thread Mike Bayer
a column name isn't "escaped", it's quoted. The quoting logic in a compiler goes through compiler.preparer.quote(column.name), if the name needs to be quoted it will come back as such. On 06/14/2016 05:16 AM, Вадим Гухман wrote: Hi, I'm trying to create a small library with utils and

Re: [sqlalchemy] nullable dates

2016-06-14 Thread Mike Bayer
Let's do an MCVE: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) end_date = Column(Date(),nullable=True) e =

Re: [sqlalchemy] Bug with join?

2016-06-14 Thread Drachenfels
> > > Article has a foreign key to Video and Video has a foreign key to Tag so > these can be joined either way. > This is a bit information I missed to be honest. I forgot that while Article has direct join to Video, Video can be joined to Article via Tag. I checked my relations so many

[sqlalchemy] nullable dates

2016-06-14 Thread Marco Correia
Hi, I have a date column which is optional, therefore I created it like this: end_date = Column(Date(),nullable=True) Apparently, if I do not specify the date, the database (mysql) stores "-00-00". This is a problem later, when I do queries using clauses like the following:

[sqlalchemy] How to make escaped column names in sqlalchemy

2016-06-14 Thread Вадим Гухман
Hi, I'm trying to create a small library with utils and compilers for sqlalchemy that extends sqlalchemy default functionality. Right now it has two compilers. One for Date and one for merge-like statement. I have a problem with on duplicate key update statement in mysql that I've summarized