Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread mike bayer
On 11/11/2016 12:18 PM, Michael Williamson wrote: That still requires the repetition of the name of the attribute, which I'd rather avoid. I've put together a variation on hybrid_property which automatically assigns the label by scanning through the class dict. It could probably do with a bit

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Fri, 11 Nov 2016 11:59:52 -0500 mike bayer wrote: > > > On 11/11/2016 07:20 AM, Michael Williamson wrote: > > I'm using hybrid_property, and would like the key of the property > > to be set to the attribute name, rather than the name of the > > getter. This is

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread mike bayer
On 11/11/2016 07:20 AM, Michael Williamson wrote: I'm using hybrid_property, and would like the key of the property to be set to the attribute name, rather than the name of the getter. This is because I'm generating a getter function based on some args, rather than having the caller directly

Re: [sqlalchemy] Python datatime object issue with SQLite/SQLAlchemy

2016-11-11 Thread Greg M. Silverman
I should add: The specific queries I was running that were throwing the error all worked using your test case setup. Greg-- On Fri, Nov 11, 2016 at 10:50 AM, Greg M. Silverman wrote: > Hi Mike, > Modifications of your test made to point to the actual database file I am >

Re: [sqlalchemy] Python datatime object issue with SQLite/SQLAlchemy

2016-11-11 Thread Greg M. Silverman
Hi Mike, Modifications of your test made to point to the actual database file I am using worked. The only difference in your test versus my code is that my ClinicalData class definition uses a Flask db.Model versus a straight declarative_base. I'll need to play around with this a bit more.

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
On Friday, November 11, 2016 at 2:22:28 PM UTC, Simon King wrote: > > On Fri, Nov 11, 2016 at 1:53 PM, Michael Williamson > wrote: > > > >> I think your code is basically fine, you've just got a mistake on the > >> last line. Presumably you meant to query Person, not

Re: [sqlalchemy] How to reflect database with auto quote_name of __tablename__ ?

2016-11-11 Thread mike bayer
SQLAlchemy has a case sensitivity behavior that assumes an all lowercase name to indicate "case insensitive". Firebird and Oracle both use ALL_UPPERCASE to indicate "case insensitive". SQLAlchemy converts between these two. Therefore if your table shows up in Firebird as SOME_TABLE,

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 1:53 PM, Michael Williamson wrote: > >> I think your code is basically fine, you've just got a mistake on the >> last line. Presumably you meant to query Person, not Person.born? > > > I want Person.born so that I don't have to get the entire object. It

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
> I think your code is basically fine, you've just got a mistake on the > last line. Presumably you meant to query Person, not Person.born? > I want Person.born so that I don't have to get the entire object. It doesn't make much difference in this example, but is quite important for us in

Re: [sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 12:20 PM, Michael Williamson wrote: > I'm using hybrid_property, and would like the key of the property to be set > to the attribute name, rather than the name of the getter. This is because > I'm generating a getter function based on some args, rather

[sqlalchemy] Setting key of hybrid_property to attribute name rather than function name

2016-11-11 Thread Michael Williamson
I'm using hybrid_property, and would like the key of the property to be set to the attribute name, rather than the name of the getter. This is because I'm generating a getter function based on some args, rather than having the caller directly defining the getter. As a minimal example: from

[sqlalchemy] How to reflect database with auto quote_name of __tablename__ ?

2016-11-11 Thread uralbash
Hello, I'm trying to reflect existing FireBird database like metadata.reflect(engine) it's works ok with UPPERCASE tablename but with lowercase name raise exception: reflection.py, line 598, in reflecttable raise exc.NoSuchTableError(table.name) sqlalchemy.exc.NoSuchTableError: foo_states

Re: [sqlalchemy] Re: One to One relationship

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 6:59 AM, Alfred Soeng wrote: > It's the issue in the inheritance: > What I want to do is like this: > class Employee(Base): > __tablename__ = 'employee' > id = Column( > Integer, > primary_key=True, > ) > type_name =

Re: [sqlalchemy] Flask SQLalchemy sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column todos.user_id does not exist

2016-11-11 Thread Simon King
On Fri, Nov 11, 2016 at 7:59 AM, Muhammad Aldo Firmansyah wrote: > I want to make API using flask, flask-restless and flask sqlalchemy. > Database using postgres > > Here's my model. The relation below is one-to-many (User have one or many > tasks. And a task is