Re: [sqlalchemy] A record is dropped on add

2013-10-04 Thread Werner
Michael, On 03/10/2013 23:05, Michael Bayer wrote: On Oct 3, 2013, at 5:42 AM, Werner werner.bru...@sfr.fr wrote: ... The relation setup for the classes involved, and I suspect Vintage.drinkinfo/Cellarbook.drinkinfo ones: Vintage.vintadd = sao.relationship('Vintadd', uselist=False,

[sqlalchemy] AttributeError: 'ColumnProperty' object has no attribute 'strategy'

2013-10-04 Thread kim
T_T Hi, I am using SQLAlchemy 0.8.2 with PostgreSQL and having exactly same problem. I have a lot of table classes inherited declarative base and only some of classes raise errors. (https://gist.github.com/yoloseem/d1c9b0f8d3cef6c196e4 ) Actually, even for same buggy classes, errors are

[sqlalchemy] Query for date between a range

2013-10-04 Thread Enrico Morelli
Dear all, I've a table where the date is separated in single fields, one for year, one for day and one for month. So I need to query for a date range. I search in Internet and I found the following query that seems to be works: SELECT * FROM plan WHERE year * 1 + month * 100 + day BETWEEN

RE: [sqlalchemy] Query for date between a range

2013-10-04 Thread Ofir Herzas
You can create a custom field in your model and check against it: class Plan(Base): . . . @property def calculated_date(self): return date(self.year, self.month, self.day) Then, in your query, use that field:

RE: [sqlalchemy] Query for date between a range

2013-10-04 Thread Ofir Herzas
I'm sorry, you should use hybrid_property: from sqlalchemy.ext.hybrid import hybrid_property class Plan(Base): @hybrid_property def calculated_date(self): return date(self.year, self.month, self.day) Also, in your query, don't use between: session.query(Plan).\

Re: [sqlalchemy] AttributeError: 'ColumnProperty' object has no attribute 'strategy'

2013-10-04 Thread Michael Bayer
this is definitely not related to any issue from 2007. See what happens if you call sqlalchemy.orm.configure_mappers() right before you emit that Query in this particular test.the error indicates this particular class was not present when the mappers post-configured themselves. On Oct

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Enrico Morelli
On Fri, 4 Oct 2013 16:25:00 +0300 Ofir Herzas herz...@gmail.com wrote: I'm sorry, you should use hybrid_property: from sqlalchemy.ext.hybrid import hybrid_property class Plan(Base): @hybrid_property def calculated_date(self): return date(self.year, self.month, self.day)

[sqlalchemy] Session Management Issues While Integrating With Old Code

2013-10-04 Thread Russell Holloway
Hello all, I am trying to migrate some custom ORM code to use SQLAlchemy instead for database interactions. I'm having some issues with proper session management. The main issue that seems to occur is the operationalerror 'mysql has gone away' with every now and then one comes up

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Enrico Morelli
On Fri, 4 Oct 2013 16:03:18 +0200 Enrico Morelli more...@cerm.unifi.it wrote: On Fri, 4 Oct 2013 16:25:00 +0300 Ofir Herzas herz...@gmail.com wrote: I'm sorry, you should use hybrid_property: from sqlalchemy.ext.hybrid import hybrid_property class Plan(Base):

Re: [sqlalchemy] Session Management Issues While Integrating With Old Code

2013-10-04 Thread Simon King
On Fri, Oct 4, 2013 at 3:47 PM, Russell Holloway russ.d.hollo...@gmail.com wrote: Hello all, I am trying to migrate some custom ORM code to use SQLAlchemy instead for database interactions. I'm having some issues with proper session management. The main issue that seems to occur is the

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Simon King
I'm not sure that will work on it's own, will it? When used in a class context (Plan.calculated_date), you will end up calling the date function with 3 SQLAlchemy column objects, which won't work. At a minimum, you'd need this: class Plan(Base): @hybrid_property def

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Jonathan Vanasco
That query looks weird. I'd suggest converting everything to a date in the database and having the db sort it -- on postgres it would look like this -- create table test_date ( id serial primary key not null , int , mm int , dd int ); select * from test_date where (

RE: [sqlalchemy] Query for date between a range

2013-10-04 Thread Ofir Herzas
Enrico, It should be available on 0.7.10 Simon, you are right. The expression is indeed a must. class Plan(Base): @hybrid_property def calculated_date(self): return date(self.year, self.month, self.day) @calculated_date.expression def calculated_date(self):

Re: [sqlalchemy] textcolumn.contains() escaping, the lack of icontains(), and possible bug?

2013-10-04 Thread Bobby Impollonia
Converting strings to lower case and comparing them is not the same as a true case-insensitive comparison. Python 3.3 adds a str.casefold method for this reason. The docs for that method give a good explanation of the distinction: Casefolding is similar to lowercasing but more aggressive

[sqlalchemy] CreateTable display is not right for autoincrement in mysql

2013-10-04 Thread limodou
Today I found if I have an id column in a table, and the autoincrement attribute is True, when I created the table it's right, but when I print the create statment is not right for autoincrement. The testing code is: from sqlalchemy import * from sqlalchemy.schema import CreateTable engine =