Re: [sqlalchemy] Refactoring events / triggers into Mixins

2018-11-08 Thread Luke
. - Luke -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you

Re: [sqlalchemy] Refactoring events / triggers into Mixins

2018-11-07 Thread Luke
It's as simple as cls.__name__ isn't it? Thanks again. - Luke PS: Some people on this list may find my (very alpha) pytest-pgtap library helpful: https://github.com/lmergner/pytest-pgtap -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchem

Re: [sqlalchemy] Refactoring events / triggers into Mixins

2018-11-07 Thread Luke
s me I need to insert the __tablename__ of the subclass into my DDL statement. Does SqlAlchemy have a way to do this? - Luke -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verif

[sqlalchemy] Refactoring events / triggers into Mixins

2018-11-07 Thread Luke
quot;after_create", cls._trigger_ddl.execute_if(dialect="postgresql"), ) ``` When __abstract__ = True the subclass is unmapped and no ddl is emitted on create_all(). I did not expect that. Is it possible to have the Mixin execute the event.listen or otherwise

[sqlalchemy] polymorphic inheritance where an engineer is also a manager

2018-01-20 Thread Luke
hip as long as all Managers are also Engineers. Is there a simpler way to accomplish this goal or am I thinking about the problem incorrectly? Thanks in advance, Luke Mergner Glendale, CA -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post e

Re: [sqlalchemy] Adjacency with Inherited Classes

2014-02-24 Thread Luke
On Monday, February 24, 2014 1:12:59 PM UTC-8, Luke wrote: > > > > On Monday, February 24, 2014 12:55:16 PM UTC-8, Michael Bayer wrote: >> >> >> On Feb 24, 2014, at 2:41 PM, Luke wrote: >> >> Hi, >> >> >> >> class Response(Wri

Re: [sqlalchemy] Adjacency with Inherited Classes

2014-02-24 Thread Luke
On Monday, February 24, 2014 12:55:16 PM UTC-8, Michael Bayer wrote: > > > On Feb 24, 2014, at 2:41 PM, Luke > wrote: > > Hi, > > > > class Response(Writing): > # All responses are associated with Writing. Writing/Articles may have > # several re

[sqlalchemy] Adjacency with Inherited Classes

2014-02-24 Thread Luke
xception: sqlalchemy.exc.AmbiguousForeignKeysError: Can't determine join between 'writing' and 'response'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly. Thank you for help and

Re: [sqlalchemy] How to use classes derived from declarative_base for default columns

2013-08-15 Thread Luke
Hey Werner, thanks for the hint. i got the correct answer via IRC now. I'm using http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#mixin-and-custom-base-classes to achieve my goal. Luke -- You received this message because you are subscribed to the Google G

[sqlalchemy] How to use classes derived from declarative_base for default columns

2013-08-15 Thread Luke
Hey, how may i extend the declerative base to provide default things that are always available to any class/table that is derived from it (like primary keys, create timestamp columns ect) ? i tried something like this: import datetime from sqlalchemy.ext.declarative import declarative_base from

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-15 Thread Luke Arno
sing quote_schema=False and adding a "." to the end of the schema value (schema="DBNAME.") but this results in the broken SQL mentioned earlier: SELECT [LeftTable_1].description AS [DBNAME._LeftTab_1] Using schema="DBNAME.SCHEMANAME" didn't work either. Please let me know ho

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Luke Arno
ch work it would be, but it _sounds_ easy. :) Thanks. - Luke On Wed, Oct 14, 2009 at 3:01 PM, Luke Arno wrote: > Thanks, Simon. Good suggestion, but these are databases and not > schema within a database. If I use the schema="MyDatabase." ( > notice the ".") and q

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Luke Arno
y they are. :( On Wed, Oct 14, 2009 at 11:51 AM, King Simon-NFHD78 wrote: > > > -Original Message- > > From: sqlalchemy@googlegroups.com > > [mailto:sqlalch...@googlegroups.com] On Behalf Of Luke Arno > > Sent: 14 October 2009 16:41 > > To: sqlalchemy@googleg

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-14 Thread Luke Arno
e names... BTW, sorry for not putting [sqlalchemy] in my subject line. Thanks! - Luke On Wed, Oct 14, 2009 at 10:01 AM, Michael Bayer wrote: > > Luke Arno wrote: > > I have a MSSQL server with two logical databases. (I inherited this > > situation, > > of course.) The

[sqlalchemy] ORM Many to Many Across Two Databases

2009-10-13 Thread Luke Arno
ss Right(object): pass mapper(Left, left_table) mapper(Right, right_table, properties={ 'lefts': relation(Left, secondary=assoc_table, primaryjoin=right_table.c.id==assoc_table.c.right_id, secondaryjoin=assoc_table.c.left_id==left_table

[sqlalchemy] dynamic creation of tables

2009-06-27 Thread Luke Peterson
x27;notnull'] == True: rollingfields = rollingfields + ", nullable=False" rollingfields = rollingfields + ")" rollingfields = rollingfields + ")" eval(rollingfields) meta.create_all(execengine) - Luke Peterso

[sqlalchemy] Re: generate_series?

2008-04-26 Thread Luke Iannini
ne 3323, in oid_column oid = f.oid_column AttributeError: '_TextFromClause' object has no attribute 'oid_column' when trying to union_all the result of a (on its own, seemingly working) generate_series select a manifestation of the bug you mentioned or am I doing something else

[sqlalchemy] Re: generate_series?

2008-04-25 Thread Luke Iannini
On Apr 25, 8:46 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Apr 25, 2008, at 9:04 AM, Luke Iannini wrote: > > > > > > > Hi all, > > Is there a way to use generate_series with SQLAlchemy? > > >http://www.postgresql.org/docs/8.2/interactive/func

[sqlalchemy] generate_series?

2008-04-25 Thread Luke Iannini
27;t know how to translate "s(a)/s.a" into SQLAlchemy. As a side question, how would I add static columns to a select statement? e.g. based on the pseudocode above: zrows = select([generate_series.params(start=1, end=20).c.i], 0, 0, 0).label(&#x

[sqlalchemy] Learning SQLAlchemy - some questions on mapped selects and set-based update/delete in sessions

2007-11-13 Thread Luke Opperman
the syntax, perhaps the conversion dict's values could be sql expressions, although they'd pretty much have to be selects although context is unclear and now inserts would be different from update/delete. For 2, another consideration that might have kept this off the table so far would be

[sqlalchemy] Re: suggestion to use deferrable foreign key constraints

2007-02-24 Thread Luke Stebbing
s you want on your > instances, either before flush() or within before_insert() > operations, and SA will use those values when inserting the rows for > the instance if they are present. > > On Feb 23, 2007, at 2:03 PM, Luke Stebbing wrote: > > > > > PG and Orac

[sqlalchemy] Query.get(), minor request

2007-02-23 Thread Luke Stebbing
This is really just a minor detail, but I noticed that Query.get(None) will fail with an exception instead of returning None. It has the mapper call "identity_key_from_primary_key", and that tries to do "tuple(util.to_list(None))" -> "tuple(None)" -> TypeError. --~--~-~--~~--

[sqlalchemy] Re: suggestion to use deferrable foreign key constraints

2007-02-23 Thread Luke Stebbing
n > practice. which databases support this feature ? i didnt think it > was so common (though not surprised PG supports it). > > On Feb 22, 2007, at 1:15 PM, Luke Stebbing wrote: > > > > > Are there any plans to handle circular dependencies by using > > deferra

[sqlalchemy] suggestion to use deferrable foreign key constraints

2007-02-22 Thread Luke Stebbing
Are there any plans to handle circular dependencies by using deferrable foreign key constraints when available? In my case, I had made the foreign key constraints deferred, but SQLAlchemy didn't pick up on that when I reflected the database metadata. I eliminated the circular dependency by using

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-12 Thread Luke Stebbing
quot; so that all actions performed on the parent will propagate to the child, which will remove the need to save children directly. See here also: http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_cascade Cheers, Luke On Feb 11, 1:49 pm, "Nebur" <[EMAIL PROTECTED]> wrote: &g

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-11 Thread Luke Stebbing
backref=backref("myuser", uselist=False)) }) mapper(Userdata, t_userdata) # create 1 instance of each object: user1 = User() session.save(user1) session.flush() user1.userdata = Userdata() ### add userdata to user, relationship is automatically created ses