Re: [sqlalchemy] Re: set next value of postgres sequence

2015-12-01 Thread Jonathan Vanasco
On Tuesday, December 1, 2015 at 3:39:02 PM UTC-5, Chris Withers wrote: > > Indeed, but that's not quite what I asked ;-) > > I'm after setting the next value using, eg, setval: > > Ah, sorry. I saw "next value" and thought "nextval", not setval. The `Sequence` object just seems to support a

Re: [sqlalchemy] Re: set next value of postgres sequence

2015-12-01 Thread Chris Withers
Indeed, but that's not quite what I asked ;-) I'm after setting the next value using, eg, setval: http://www.postgresql.org/docs/current/static/functions-sequence.html ...or to do it on creation of the sequence: http://www.postgresql.org/docs/current/static/sql-createsequence.html I guess

[sqlalchemy] Re: postgresql, jsob and like operator

2015-12-01 Thread Michal Nowikowski
Great, it works. Thank you very much. Regards, Michal On Tuesday, December 1, 2015 at 6:49:05 PM UTC+1, Jonathan Vanasco wrote: > > I don't think you can get that exact query staying within the ORM's > cross-platform functionality -- I don't think there is anything that can > generate the `::`

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Jonathan Vanasco
I think this story may have some related info - https://bitbucket.org/zzzeek/sqlalchemy/issues/3442/no-control-of-ddl-sequences-for-indexes-fk disclaimer -- I merely saw this earlier today and remembered it when seeing this post. -- You received this message because you are subscribed to

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Chris Withers
Does the .listen example there work or does it need the patch to land? On 01/12/2015 21:47, Jonathan Vanasco wrote: I think this story may have some related info - https://bitbucket.org/zzzeek/sqlalchemy/issues/3442/no-control-of-ddl-sequences-for-indexes-fk disclaimer -- I merely saw this

Re: [sqlalchemy] Re: postgresql, jsob and like operator

2015-12-01 Thread Mike Bayer
On 12/01/2015 12:49 PM, Jonathan Vanasco wrote: > I don't think you can get that exact query staying within the ORM's > cross-platform functionality -- I don't think there is anything that can > generate the `::` version of casting... but I think something like this > should produce the same

[sqlalchemy] post_update issue

2015-12-01 Thread Thorsten von Stein
The following issue, which puzzled for several days, exists in several versions. I verified that it applies to version 1.0.9 In my understanding, the post_update flag is required on a relationship between to classes A and B if there is another relationship between B and A in order to break a

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Mike Bayer
On 12/01/2015 02:49 PM, Chris Withers wrote: > On Tue, Dec 1, 2015 at 8:17 AM, Chris Withers > <ch...@simplistix.co.uk> wrote: >> >> I'm also looking for two events to listen to: >> >> - once at 'database creation' time, so set up some stored >>

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Jonathan Vanasco
On Tuesday, December 1, 2015 at 5:02:28 PM UTC-5, Chris Withers wrote: > > Does the .listen example there work or does it need the patch to land? > The ticket is still open, so the patch is probably needed (and looks to be Michael's first attempt at making something pass). -- You received

Re: [sqlalchemy] Re: postgresql, jsob and like operator

2015-12-01 Thread Jonathan Vanasco
On Tuesday, December 1, 2015 at 7:12:15 PM UTC-5, Michael Bayer wrote: see also the JSON operators which have some built-in text casting stuff: > > > http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html?highlight=json#sqlalchemy.dialects.postgresql.JSON > > > this is also getting

[sqlalchemy] Re: postgresql, jsob and like operator

2015-12-01 Thread Jonathan Vanasco
I don't think you can get that exact query staying within the ORM's cross-platform functionality -- I don't think there is anything that can generate the `::` version of casting... but I think something like this should produce the same output: r = session.query( Device.id, Device.name,

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Chris Withers
On 02/12/2015 00:08, Mike Bayer wrote: On 12/01/2015 02:49 PM, Chris Withers wrote: - once at 'database creation' time, so set up some stored procedures. (I know SQLAlchemy doesn't create databases itself, so interested in the correct approach for this) So, thinking this

Re: [sqlalchemy] after_create event for all uses of a mixin

2015-12-01 Thread Chris Withers
On 01/12/2015 10:10, Simon King wrote: On Tue, Dec 1, 2015 at 8:17 AM, Chris Withers > wrote: Hi All, Where can I find documentation on the parameters taken by event.listen? I have some listeners on instrument_class that

Re: [sqlalchemy] non-table DDL elements and MetaData objects

2015-12-01 Thread Chris Withers
On Tue, Dec 1, 2015 at 8:17 AM, Chris Withers > wrote: I'm also looking for two events to listen to: - once at 'database creation' time, so set up some stored procedures. (I know SQLAlchemy doesn't create databases itself, so

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread Simon King
I don't understand exactly what you are trying to do here, from a database perspective. Your table setup suggests that you are using joined-table inheritance: http://docs.sqlalchemy.org/en/rel_1_0/orm/inheritance.html#joined-table-inheritance ie. attributes that are common to all classes in the

Re: [sqlalchemy] event.listen questions

2015-12-01 Thread Simon King
On Tue, Dec 1, 2015 at 8:17 AM, Chris Withers wrote: > Hi All, > > Where can I find documentation on the parameters taken by event.listen? > I have some listeners on instrument_class that pass propagate=True, but I > can't find docs on what that means? > I think the

[sqlalchemy] event.listen questions

2015-12-01 Thread Chris Withers
Hi All, Where can I find documentation on the parameters taken by event.listen? I have some listeners on instrument_class that pass propagate=True, but I can't find docs on what that means? I'm also looking for two events to listen to: - once at 'database creation' time, so set up some

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread amit geron
Hi Simon, Thanks for the reply. I will try to better explain what I was trying to do: - Created a general class User, which has a index (id) and unique attribute (email). - Created 2 sub-classes of User: Patient and Doctor, with primary foreign key User.id. - Basic assumption

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread Simon King
If someone can be both a Doctor and a Patient at the same time, I don't think 2 classes inheriting from User can really work any more. Off the top of my head, I might start with something like this (completely untested, and the names are horrible, but hopefully you get the idea) class User(Base):

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread amit geron
Thanks again for your answers. Although this seems like an elegant solution, I would still want to know is what is the reason for this limitation: "If someone can be both a Doctor and a Patient at the same time, I don't think 2 classes inheriting from User can really work any more" - Why?

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread Simon King
Well, this is a limitation of traditional object-oriented design (at least in Python - I can't think of any other languages which would allow it either). An object can only be an instance of a single class. In python, objects have a "__class__" attribute which points to the class they are an

Re: [sqlalchemy] Re: Creating a derived class object without inserting into base class table

2015-12-01 Thread amit geron
Thanks again for the detailed explanation. I think I now understand. Amit On Tuesday, December 1, 2015 at 6:15:02 PM UTC+2, Simon King wrote: > > Well, this is a limitation of traditional object-oriented design (at least > in Python - I can't think of any other languages which would allow it >