[sqlalchemy] Re: Polymorphic union of two sibling classes (no real inheritance)

2010-07-29 Thread Kent
, cascade='refresh-expire,expunge', lazy=False), 'paymenttype': relation(PaymentType, cascade='refresh-expire,expunge', lazy=False)} ) On Jul 29, 4:20 pm, Kent Bower k...@retailarchitects.com wrote: No, in fact, there is no ArTranBase table

Re: [sqlalchemy] Re: Polymorphic union of two sibling classes (no real inheritance)

2010-07-29 Thread Kent Bower
it seems like you want the polymorphic_union here, when you query ArTranBase and you want it to eagerly load trancode and paymenttype, it would need to have a relation() on the ArTranBase mapper so that it knows what to join. On Jul 29, 2010, at 4:46 PM, Kent wrote: This seems to work

[sqlalchemy] finding mapper from table

2010-07-13 Thread Kent
I know how to get the mapper given a class or object. How do I find the mapper or class given the table? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this

[sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Kent
Say I track Inventory with three classes: Product, Inventory, Location This any() expression yields the following output. session.query(Product).filter(Product.inventory.any(Location.siteid==u'EAST')).all() SELECT ... FROM products WHERE EXISTS (SELECT 1 FROM inventory, locations WHERE

Re: [sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Kent Bower
= inventory.locationid WHERE locations.siteid = :siteid_1 Any idea what I am doing wrong? On 6/4/2010 4:37 PM, Conor wrote: On 06/04/2010 03:13 PM, Kent wrote: Say I track Inventory with three classes: Product, Inventory, Location This any() expression yields the following output. session.query

Re: [sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-31 Thread Kent Bower
On 5/30/2010 1:24 PM, Michael Bayer wrote: On May 28, 2010, at 1:46 PM, Kent Bower wrote: On 5/28/2010 10:08 AM, Michael Bayer wrote: Is the pattern that you want to keep re-issuing a savepoint repeatedly using the same name ? Does that have some different usage of resources versus

Re: [sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-31 Thread Kent Bower
On 5/31/2010 9:55 AM, Michael Bayer wrote: On May 31, 2010, at 8:24 AM, Kent Bower wrote: Although sqla doesn't allow the user to specify the savepoint name, the same could be accomplished given if support for the following were implemented: Let me ask: sp_a=begin_nested

[sqlalchemy] zope.sqlalchemy with sqla 0.6

2010-05-31 Thread Kent
for looking into this. Let me know if I can help further. Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr

Re: [sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-28 Thread Kent Bower
* Is there a way besides session.commit() to free the savepoint resource? Is there a way to provide the savepoint name, so I can use the same name over? Lastly, if you aren't the expert, where would you point me, zope group or TG group? you could issue the SAVEPOINT instructions

Re: [sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-28 Thread Kent Bower
From a quick reading of the 'transaction' package source, it looks like you should be able to create savepoints and roll them back something like this: savepoint = transaction.savepoint() try: # ... except: savepoint.rollback() raise Thanks for the interest in helping. I

[sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-28 Thread Kent
commit? I assume the answer is yes, that is by design. Which leads to this question: Inside a SessionExtension's before_commit() method, how can I work out whether this is a nested transaction vs. the root transaction? Thanks, Kent -- You received this message because you are subscribed

[sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-28 Thread Kent
Is the answer to second questoin session.transaction.nested? On May 28, 1:24 pm, Kent k...@retailarchitects.com wrote: On May 27, 6:39 pm, Michael Bayer mike...@zzzcomputing.com wrote: commit() releases the savepoint, if thats whats going on contextually.   It doesnt actually commit

Re: [sqlalchemy] Re: For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-28 Thread Kent Bower
On 5/28/2010 10:08 AM, Michael Bayer wrote: Is the pattern that you want to keep re-issuing a savepoint repeatedly using the same name ? Does that have some different usage of resources versus issuing/closing distinct savepoints with different names ? As an aside, since oracle apparently has

[sqlalchemy] For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-27 Thread Kent
The docs state For each begin_nested() call, a corresponding rollback() or commit() must be issued. In PostgreSql, according to my understanding, if there is ever a database exception, a rollback must be issued. This means a main reason to issue a SAVEPOINT is as a hedge against an error. As

Re: [sqlalchemy] For each begin_nested() call, a corresponding rollback() or commit() must be issued.

2010-05-27 Thread Kent Bower
201, in before_commit assert zope_transaction.get().status == 'Committing', Transaction must be committed using the transaction manager AssertionError: Transaction must be committed using the transaction manager On 5/27/2010 6:39 PM, Michael Bayer wrote: On May 27, 2010, at 5:12 PM, Kent

[sqlalchemy] mapper properties' class types: SynonymProperty

2010-05-25 Thread Kent
When introspecting a mapper, we can figure out the class type of its properties like this: For ColumnProperty: prop.columns[0].type.__class__ For RelationProperty (relationship): prop.argument For RelationProperty (backref): prop.argument.class_ How do I determine the class type a

[sqlalchemy] Re: mapper properties' class types: SynonymProperty

2010-05-25 Thread Kent
One answer is, I believe, use the name property to access the mapped property, like this: prop.parent.get_property(prop.name) Is there a better way? On May 25, 8:54 am, Kent k...@retailarchitects.com wrote: When introspecting a mapper, we can figure out the class type of its properties like

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent
Ignore everything below unicode_for_unicode = False for Oracle lower than 9? in previous post, I meant to delete those lines -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent
SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM DUAL then it seems like either that fails directly, or it fails when the client gets a hold of it.   See what happens with that statement.   Not sure that Oracle 8 has NVARCHAR which might be the issue. Please see the

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent
* ERROR at line 1: ORA-00907: missing right parenthesis = On May 18, 12:15 pm, Kent k...@retailarchitects.com wrote: SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM DUAL then it seems like either that fails

Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent Bower
/2010 1:17 PM, Michael Bayer wrote: Sorry, I meant NVARCHAR2. SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL works ? or no ? On May 18, 2010, at 12:17 PM, Kent wrote: Oops, my bad, I didn't notice you that statement changed NVARCHAR2 to NVARCHAR: Here

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent
version. It also states you can *not* store Unicode in the NCHAR datatype until Oracle 9i. On May 18, 1:23 pm, Kent Bower k...@retailarchitects.com wrote: No, this is what was causing ORA-12704: character set mismatch: SQL SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent
VARCHAR2 for unicode data.  i wasn't aware of the N- types at that time. also the suite of changes here is going to roll in the use_ansi flag into the oracle 8 detection, its a bit redundant to require it manually. On May 18, 2010, at 1:29 PM, Kent wrote: There is a fairly short Oracle

[sqlalchemy] Re: is sqlalchemy-migrate the right way to go?

2010-05-17 Thread Kent
We will definitely also need a migration tool. We've only briefly looked into the sqlalchemy-migrate tool, but were immediately disappointed in its apparent requirement to keep versions of the schema. In our book, we see the ideal tool as one that doesn't care about versions: it just looks at the

[sqlalchemy] sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-17 Thread Kent
After migrating to 0.6, we've got an apparently well running application for postgres and Oracle 9 or above. However, as soon as we connect to an Oracle 8 database, *everything* we attempt ends with this: oracle error: ORA-00907: missing right parenthesis Here is an example trying to run a

Re: [sqlalchemy] Re: is sqlalchemy-migrate the right way to go?

2010-05-17 Thread Kent Bower
Thanks, that looks like its conceptually what we are hoping for, at least. On 5/17/2010 3:58 PM, Tamás Bajusz wrote: On Mon, May 17, 2010 at 9:49 PM, Kentk...@retailarchitects.com wrote: Ideally, I agree. Practically speaking, though, we came from a company where dozens and dozens of

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-17 Thread Kent
this particular interaction doesn't go through regular SQLAlchemy logging.   If you really needed to see it occur you'd have to watch your oracle query logs. On May 17, 2010, at 3:37 PM, Kent wrote: After migrating to 0.6, we've got an apparently well running application for postgres

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-17 Thread Kent
Sorry, posted too quickly, I'll get the rest of the results you asked about... On May 17, 4:56 pm, Kent k...@retailarchitects.com wrote: Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production With the Partitioning option JServer Release 8.1.7.4.0 - Production Session

[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-17 Thread Kent
sqlalchemy.engine.base.Engine.0x...fb50 {} ORA-12704: character set mismatch (8, 1, 7, 4, 0) On May 17, 4:58 pm, Kent k...@retailarchitects.com wrote: Sorry, posted too quickly, I'll get the rest of the results you asked about... On May 17, 4:56 pm, Kent k...@retailarchitects.com wrote

Re: [sqlalchemy] allow_partial_pks=False goes to database on partial pk

2010-05-11 Thread Kent Bower
:21 PM, Kent wrote: See this script, running 0.6.0: == from sqlalchemy import * from sqlalchemy.orm import * engine = create_engine('oracle://user:passw...@localhost:1521/xe? use_ansi=False',echo=True) metadata = MetaData() Session = sessionmaker

[sqlalchemy] allow_partial_pks=False goes to database on partial pk

2010-05-10 Thread Kent
See this script, running 0.6.0: == from sqlalchemy import * from sqlalchemy.orm import * engine = create_engine('oracle://user:passw...@localhost:1521/xe? use_ansi=False',echo=True) metadata = MetaData() Session = sessionmaker(bind=engine) session

[sqlalchemy] Re: [Distutils] inability to pass setup.py command line arguments to dependency setups

2010-05-07 Thread Kent Bower
approach and I'll forward this idea to an author of SQLAlchemy for his consideration. On 5/7/2010 1:33 PM, Glyph Lefkowitz wrote: On May 7, 2010, at 9:09 AM, Kent wrote: Consider the case where you want your setup to install third-party software, but you want/need to pass an argument

[sqlalchemy] Re: [Distutils] inability to pass setup.py command line arguments to dependency setups

2010-05-07 Thread Kent
Mike, Can I just take a second to thank you for your patience in running this forum? There are so many rude, arrogant software developers, and you seem to not be like them at all. Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] Numeric not consistent between Postgres and Oracle in 0.6

2010-05-06 Thread Kent Bower
The following has changed since 0.5.8 in 0.6.0. I believe this is already known or by design from reading docs and another post but want to point out. If you specify a column such as this: Column(saleprice, Numeric, nullable=False) you get a 'numeric' type in PostgreSQL, which supports

[sqlalchemy] Re: Numeric not consistent between Postgres and Oracle in 0.6

2010-05-06 Thread Kent
I guess my suggestion is: since Oracle takes DECIMAL and NUMERIC to mean NUMBER(38), if SQLAlchemy interprets the generic types DECIMAL or Numeric with no precision to allow for decimal or integer values, we should translate that to 'NUMBER' for Oracle... Thoughts? On May 6, 12:11 pm, Kent

[sqlalchemy] joins use old data

2010-05-06 Thread Kent
seems wrong. A longer term enhancement to sqla might be to automatically expire any relation whose join columns include a column that gets updated in a session? Is that a manageable effort? Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] disable RETURNING for specific primary key columns

2010-05-04 Thread Kent
are on a legacy oracle system or a postgres database. In some cases the 'tables' are views that don't support RETURNING, so I'd like to turn it off for those cases only...) Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

Re: [sqlalchemy] disable RETURNING for specific primary key columns

2010-05-04 Thread Kent Bower
You think of everything? ;) Thanks On 5/4/2010 2:41 PM, Michael Bayer wrote: On May 4, 2010, at 2:30 PM, Kent wrote: I understand I can disable RETURNING for an engine with 'implicit_returning=False' Is there a way to do this for certain primary key columns only, but not disabled engine

[sqlalchemy] SQL compilation broken in 0.6 for Oracle use_ansi=False

2010-05-03 Thread Kent
The following script works as expected (also in 0.5.8) with use_ansi=True. However, with use_ansi=False, the SQL is ill-formed: === from sqlalchemy import * from sqlalchemy.orm import * engine =

Re: [sqlalchemy] SQL compilation broken in 0.6 for Oracle use_ansi=False

2010-05-03 Thread Kent Bower
. this may be a trivial issue but I cant assert that until I've had time to study it. On May 3, 2010, at 8:47 AM, Kent wrote: The following script works as expected (also in 0.5.8) with use_ansi=True. However, with use_ansi=False, the SQL is ill-formed

Re: [sqlalchemy] SQL compilation broken in 0.6 for Oracle use_ansi=False

2010-05-03 Thread Kent Bower
Thank you, sir. On May 3, 2010, at 7:33 PM, Michael Bayer mike...@zzzcomputing.com wrote: OK the issue here is entirely un-subtle and its a little weird that none of the tests we have hit upon it. this is fixed in tip. On May 3, 2010, at 12:06 PM, Kent Bower wrote: Note

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-05-01 Thread Kent
Is it rude to ask why not disable the weakidentity map? Under the turbogears web framework, our Sessions only exist for the duration of the service call, and I am finding myself appending all these objects to a no_garbage_collect list that I am keeping on the session object anyway. Then the

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-05-01 Thread Kent
, correct? In other words, for my understanding, or others reading the list, in a framework where a session's life cycle only lasted as long as a web service call, the threat of the program's memory growing unbounded is non-existent, correct? Kent -- You received this message because you

Re: [sqlalchemy] upgrade to SQLA 0.6

2010-05-01 Thread Kent Bower
May help others: instead of col in const.columns I needed col in list(const.columns) to avoid: sqlalchemy.exc.ArgumentError: __contains__ requires a string argument with the ColumnCollection object On 4/30/2010 4:16 PM, Michael Bayer wrote: Kent wrote: I did read 0.6 Migration

Re: [sqlalchemy] upgrade to SQLA 0.6

2010-05-01 Thread Kent Bower
Wait a second... ForeignKeyConstraint doesn't but PrimaryKeyConstraint does? (Not trying to be sassy, just wondering why I got the error in the first place) On 5/1/2010 2:11 PM, Michael Bayer wrote: On May 1, 2010, at 2:04 PM, Kent Bower wrote: May help others: instead of col

Re: [sqlalchemy] upgrade to SQLA 0.6

2010-05-01 Thread Kent Bower
Oh, I get it, you are saying ColumnCollection has contains_column() method. On 5/1/2010 4:05 PM, Kent Bower wrote: Wait a second... ForeignKeyConstraint doesn't but PrimaryKeyConstraint does? (Not trying to be sassy, just wondering why I got the error in the first place) On 5/1/2010 2

Re: [sqlalchemy] upgrade to SQLA 0.6

2010-05-01 Thread Kent Bower
): = On 5/1/2010 4:06 PM, Kent Bower wrote: Oh, I get it, you are saying ColumnCollection has contains_column() method. On 5/1/2010 4:05 PM, Kent Bower wrote: Wait a second... ForeignKeyConstraint doesn't but PrimaryKeyConstraint does? (Not trying to be sassy, just wondering why I got the error

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-30 Thread Kent Bower
it up in a separate session and then merge it into my main session? Then, after that, merge the transient objects into my main session? Would that get me closer? Ideally, I wouldn't want it to need 2 trips to the database. On 4/29/2010 4:48 PM, Michael Bayer wrote: Kent Bower wrote

[sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-30 Thread Kent
I think I've got a strategy that will work and doesn't mean hacking merge()... Thanks for your input, if you have inspiration, I'll still gladly hear it. On Apr 30, 8:18 am, Kent Bower k...@retailarchitects.com wrote: Thanks in advance for the discussion, hope I can continue without you

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-30 Thread Kent Bower
On 4/30/2010 11:17 AM, Michael Bayer wrote: Kent Bower wrote: Could I look it up in a separate session and then merge it into my main session? Then, after that, merge the transient objects into my main session? Would that get me closer? Ideally, I wouldn't want it to need 2 trips

[sqlalchemy] upgrade to SQLA 0.6

2010-04-30 Thread Kent
I did read 0.6 Migration document. I was using the contains_column method of ForeignKeyConstraint. Apparently removed? AttributeError: 'ForeignKeyConstraint' object has no attribute 'contains_column' Easy workaround or replacement call? -- You received this message because you are subscribed

[sqlalchemy] making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
? In the meantime, can you recommend an approach for me? (Extend the Session class?) Thanks much, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group

[sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
That sounds like it could be very useful for me, thank you for pointing me there. That could solve one of the two issues I'm facing that I listed... what about the other? On Apr 29, 11:02 am, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Before saving objects to the database, we

[sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent
that calculation. Kent wrote: That sounds like it could be very useful for me, thank you for pointing me there.  That could solve one of the two issues I'm facing that I listed... what about the other? On Apr 29, 11:02 am, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Before

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent Bower
that version of the 'orderdetails' relation) On 4/29/2010 3:59 PM, Michael Bayer wrote: Michael Bayer wrote: Kent wrote: There might be a communication problem, which an example could help clarify. I'm constrained by a legacy database that I have no control over changing. When an order

Re: [sqlalchemy] Re: making a transient copy of instances recursively at merge() time

2010-04-29 Thread Kent Bower
/2010 3:47 PM, Michael Bayer wrote: Kent wrote: There might be a communication problem, which an example could help clarify. I'm constrained by a legacy database that I have no control over changing. When an order is changed, I need to calculate the change in volume (or points) so I can update

[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
else: # assume postgres return func.coalesce How would I work that out? Thank you in advance. On Apr 2, 4:12 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Any chance you plan to make func.now consider oracle and use_ansi=False (and return sysdate

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
Thanks very much. On 4/2/2010 5:41 PM, Michael Bayer wrote: Kent wrote: Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2 arguments, no more), so maybe there is nothing

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
2 arguments. In my case, I'd rather rework the nvl() function to work on other engines besides Oracle as an alias to coalesce(), seems less ambiguous. Thanks again. On 4/2/2010 5:41 PM, Michael Bayer wrote: Kent wrote: Along the same lines, is there something we can do about nvl

[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
ian.g.ke...@gmail.com wrote: On Fri, Apr 2, 2010 at 3:41 PM, Michael Bayer mike...@zzzcomputing.comwrote: Kent wrote: Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
): sql %= %s, nvl(%%s) % clauses[i] return sql % , .join(clauses[-2:]) On 4/2/2010 7:08 PM, Ian Kelly wrote: On Fri, Apr 2, 2010 at 3:41 PM, Michael Bayer mike...@zzzcomputing.com mailto:mike...@zzzcomputing.com wrote: Kent wrote: Along the same lines, is there something we can

[sqlalchemy] Re: with_polymorphic

2010-04-02 Thread Kent
class inheritance so I can spot them if they present themselves. Any input for me or other readers at a general level? On Apr 1, 8:26 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 1, 2010, at 8:22 PM, Kent wrote: What is the difference between: session.query(Employee).join

[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
Any chance you plan to make func.now consider oracle and use_ansi=False (and return sysdate)? On Feb 3, 4:44 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Any chance SQLAlchemy has a mechanism to switch to or fromsysdatevs. current_datebased on the database dialect

[sqlalchemy] passing arguments to complicated columns

2010-04-01 Thread Kent
Mike, Suppose you have a Product object mapped to a product table. Say there is a table for promotional_prices as well, which looks something like this: PRODUCTID STORE PRICE STARTDATE ENDDATE 'SKUA''WEST' 30.99 01-Aug-2009 10-Aug-2010 'SKUA''EAST'35.99 01-Aug-2009

[sqlalchemy] Re: passing arguments to complicated columns

2010-04-01 Thread Kent
? Is that accomplished with either the association_proxy or column_property? On Apr 1, 4:19 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Mike,   Suppose you have a Product object mapped to a product table.  Say there is a table for promotional_prices as well, which looks

[sqlalchemy] Re: passing arguments to complicated columns

2010-04-01 Thread Kent
better, can I work that out as an association property? On Apr 1, 4:35 pm, Kent k...@retailarchitects.com wrote: I believe (correct me if you know better) that an line subquery is quite a bit less efficient than a join.  That was my motivation for avoiding that because there are so many rows

Re: [sqlalchemy] Re: passing arguments to complicated columns

2010-04-01 Thread Kent Bower
Thanks for the info. Still wondering, is there a way to tell the orm (a join criterion or a binary expression) use this function to find the param for the bind? On Apr 1, 2010, at 6:11 PM, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: I believe (correct me if you know better

[sqlalchemy] with_polymorphic

2010-04-01 Thread Kent
What is the difference between: session.query(Employee).join([Engineer, Manager]).\ filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q')) and session.query(Employee).with_polymorphic([Engineer, Manager]).\ filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q'))

[sqlalchemy] Sequences support for CYCLE and MIN/MAX values

2010-03-26 Thread Kent
Any plans to support MINVALUE, MAXVALUE, CYCLE, NOCYCLE for sequences (for both postgres and oracle)? I've implemented a subclass of Sequence myself, but it isn't very elegant, because I'm not familiar enough with the code to know which methods to override for create() output. -- You received

Re: [sqlalchemy] Sequences support for CYCLE and MIN/MAX values

2010-03-26 Thread Kent Bower
== 'postgres': sql += NO CYCLE else: raise Exception(RSequence is only implemented for Oracle and PostgreSQL!) How do I get a hold of the engine from within a Sequence object? On 3/26/2010 2:26 PM, Michael Bayer wrote: Kent wrote

[sqlalchemy] Re: Sequences support for CYCLE and MIN/MAX values

2010-03-26 Thread Kent
Sorry! Nevermind, your link answers that question. Thanks. On Mar 26, 4:23 pm, Kent Bower k...@retailarchitects.com wrote: Thanks for the info. Since it is NOCYCLE in oracle and NO CYCLE in postgres, I would check the engine.dialect.name in the compile, method correct

Re: [sqlalchemy] Session user data

2010-03-23 Thread Kent Bower
are they?) On Mar 22, 2010, at 9:48 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 22, 2010, at 9:06 AM, Kent wrote: I have a need to pass around session-dependent application data, such as strong references to certain objects that I don't want garbage collected so they will serve

[sqlalchemy] Session user data

2010-03-22 Thread Kent
I have a need to pass around session-dependent application data, such as strong references to certain objects that I don't want garbage collected so they will serve as a cache for the duration of the session. For example, if the application performs a get() on a SystemParameters table, I want a

[sqlalchemy] Refresh() for update

2010-03-19 Thread Kent
With query() I can add with_lockmode('for update'). Can I do so on a session.refresh()? What about a get()? I see this as a useful approach to a two phase large query, where one wants to avoid locking a large number of rows. First you would issue a non-locking query and then, once you have a

Re: [sqlalchemy] Refresh() for update

2010-03-19 Thread Kent Bower
wrote: On Mar 19, 2010, at 12:34 PM, Kent wrote: With query() I can add with_lockmode('for update'). Can I do so on a session.refresh()? What about a get()? a get() yes. a refresh() no, but that's a fine idea so I've committed a flag for that in rab5a31b4f3bf. A substitute

[sqlalchemy] Re: Refresh() for update

2010-03-19 Thread Kent
obj._sa_instance_state.sort_key?? Will that always be sorted how get() expects? Is there a more public way to get that? On Mar 19, 1:42 pm, Kent Bower k...@retailarchitects.com wrote: By the way, must get() always accept a primary key?  For composite   keys is there a shortcut to access its

[sqlalchemy] Re: defer relation load in a query more than one relation away

2010-03-18 Thread Kent
' lazy status is unaffected, even though it is in the call to lazyload(). Is that accurate? On Mar 17, 4:05 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Does defer only relate to ColumnProperty while lazyload relates to RelationProperty? Apparently I should be using

[sqlalchemy] defer relation load in a query more than one relation away

2010-03-17 Thread Kent
I have this schema (0.5.8): Order.orderdetails is a collection of OrderDetail objects (lazy=False) OrderDetail.product is a Product object (lazy=False) For some queries I want to defer the eager loading of OrderDetail.product on the orderdetails collection, but would like the

[sqlalchemy] Re: defer relation load in a query more than one relation away

2010-03-17 Thread Kent
Does defer only relate to ColumnProperty while lazyload relates to RelationProperty? Apparently I should be using lazyload() instead of defer()? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Decimal() with Oracle

2010-03-09 Thread Kent
I've got a column defined as this: Column(cost, Numeric, nullable=False) In Oracle, it seems I can't take advantage of the Decimal() class. I get rounding errors as if using float instead of Decimal, see output for Oracle vs. Postgres. Oracle 8i (use_ansi=False):

[sqlalchemy] preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
If I use session.refresh(obj) to re-load an obj that has a one-to-many relational property, the objects in the list are *replaced* instead of *refreshed* if they already exist. Suppose department has a list of employees: suppose dept.employees = [ emp1, emp2 ] session.refresh(dept) the

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
and creates new ones. The mystery to me is what determines when it will create new instances vs. refreshing the existing ones? On Mar 4, 3:24 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: If I use session.refresh(obj) to re-load an obj that has a one-to-many relational property

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
in the session, not marked as dirty, and strongly referenced on the outside.   if you're using refresh you shouldn't care about how it gets data back into the collection. Kent wrote: What's strange is that I can't recreate the problem on more simple stage.  Every time I refresh() on the parent

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
expunge them? On Mar 4, 4:09 pm, Conor conor.edward.da...@gmail.com wrote: Conor wrote: Kent wrote: I agree I shouldn't care, so maybe there is another way to attack my problem.  The reason I care is because I've extended the python object with some auxiliary information that I need.  After

[sqlalchemy] Re: preserving uselist relation instances in a session.refresh()

2010-03-04 Thread Kent
Ok, I wonder the reasons, but I trust your answer completely, so I won't disable it. Thanks for your help again. On Mar 4, 4:26 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Thanks... that is very helpful.  I could keep references to these.  If I choose the apparently lazier

[sqlalchemy] trying to not reinvent the wheel

2010-02-26 Thread Kent
I'm certain sqlalchemy's got a function call in its guts that I was about to recreate from scratch, so I'm hoping you can spare me the trouble. I'm trying to construct the foreign key where clause and from clause needed to populate a relation. I'd explain how I got here, but might take several

[sqlalchemy] Re: trying to not reinvent the wheel

2010-02-26 Thread Kent
Sorry, assume instead of class Order, I've got class Product(object): pass On Feb 26, 1:48 pm, Kent k...@retailarchitects.com wrote: I'm certain sqlalchemy's got a function call in its guts that I was about to recreate from scratch, so I'm hoping you can spare me the trouble. I'm

[sqlalchemy] Re: trying to not reinvent the wheel

2010-02-26 Thread Kent
Sorry, also realized the object would be *pending* instead of transient, but it will not have a flush() ever issued due to detected errors. I don't seem to think the fact that it is pending instead of transient matters, but wanted to clarify. On Feb 26, 1:51 pm, Kent k...@retailarchitects.com

[sqlalchemy] Re: trying to not reinvent the wheel

2010-02-26 Thread Kent
mike...@zzzcomputing.com wrote: On Feb 26, 2010, at 1:48 PM, Kent wrote: I'm certain sqlalchemy's got a function call in its guts that I was about to recreate from scratch, so I'm hoping you can spare me the trouble. I'm trying to construct the foreign key where clause and from clause

[sqlalchemy] Re: trying to not reinvent the wheel

2010-02-26 Thread Kent
is persistent before querying the database (doubt that's possible?)? On Feb 26, 3:23 pm, Kent k...@retailarchitects.com wrote: It *sounds* like exactly what I'm looking for, but when I try a simple example, it doesn't seem to work: ol=OrderDetail() ol.productid = 'DININGCHAIR

[sqlalchemy] Re: trying to not reinvent the wheel

2010-02-26 Thread Kent
= RelationProperty.argument.class_ #for backrefs, apparently else: cls = RelationProperty.argument To get the order of the ident keys to pass to session.query().get(): class_mapper(cls).primary_key Seems there might be an easier way, I'd very much like to hear it. On Feb 26, 3:31 pm, Kent k

[sqlalchemy] Re: merge() expires attributes

2010-02-23 Thread Kent
Bayer wrote: On Feb 20, 2010, at 5:12 PM, Kent wrote: If I have a persistent instance in my session and I call merge on an object that equates to that instance, some attributes (it seems those that aren't explicitly set on the merging instance) are expired and get re-queried the next time

[sqlalchemy] merge() expires attributes

2010-02-20 Thread Kent
If I have a persistent instance in my session and I call merge on an object that equates to that instance, some attributes (it seems those that aren't explicitly set on the merging instance) are expired and get re-queried the next time they are referenced. We will be supporting remote databases

[sqlalchemy] relation for single table, not joined

2010-02-19 Thread Kent
Suppose I have a database table, as an example, employee that has a column dept, but the dept is not represented by any other table in the database, it is just an attribute of employee. I would like to be able to create a standalone relation on a class that has no table so that I can assign lists

[sqlalchemy] Re: relation for single table, not joined

2010-02-19 Thread Kent
In case the point wasn't clear, I'd like merge() to be able to figure out which items to add, update and, esp, delete without needing to do that programatically myself. On Feb 19, 7:26 am, Kent k...@retailarchitects.com wrote: Suppose I have a database table, as an example, employee that has

[sqlalchemy] Re: relation for single table, not joined

2010-02-19 Thread Kent
, which is mapped to the employee table): empa = ... empb = ... empc = ... department.dept = 'PAYROLL' department.employees = [ empa, empb, empc ] session.merge(department) On Feb 19, 10:54 am, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 19, 2010, at 7:26 AM, Kent wrote: Suppose I

[sqlalchemy] Re: relation for single table, not joined

2010-02-19 Thread Kent
, as always. On Feb 19, 3:11 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 19, 2010, at 11:55 AM, Kent wrote: In my example, there is only *one* table, employee.  Yes, dept would be a string column on employee. The catch is there is *no* department table. but what does

[sqlalchemy] Zope scoped session autoflush seems to not function properly

2010-02-13 Thread Kent
I'm using sqla 0.5.8 with turbogears, which uses zope (I admit ignorance to what zope does, sorry) When I try to turn autoflush off because I want to make numerous changes and require queries in the meantime, the flush happens anyway when I attempt to query. Over-simplified example demonstrating

[sqlalchemy] Re: Zope scoped session autoflush seems to not function properly

2010-02-13 Thread Kent
 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 13, 2010, at 7:05 PM, Kent wrote: # want to do more queries and change more, so set autoflush to False DBSession.autoflush = False yeah sorry here, autoflush isn't propagated in 0.5.8 to the actual session when using

[sqlalchemy] inspecting whether a mapped property has been set without referencing it

2010-02-12 Thread Kent
If I have a one to many RelationProperty, which uses a list, how can I check if this has been set without actually referencing it? It seems once I reference it, it sets it to an empty list if it hasn't been set already. -- You received this message because you are subscribed to the Google

<    1   2   3   4   >