[sqlalchemy] Re: concurent modification

2007-11-30 Thread Michael Bayer
On Nov 30, 6:21 pm, imgrey <[EMAIL PROTECTED]> wrote: > > But how to determine if record is exists and update if it does or > insert instead without executing select, which would be very slow ? > I'm using nested begin_nested() here to avoid rollback of whole > transaction. you should select()

[sqlalchemy] Re: Type of calculated columns

2007-11-30 Thread Michael Bayer
yes...add type_=DateTime to your coalesce() call - func.coalesce(date1, date2, type_=DateTime) when we implement ticket #615, standard functions like "coalesce" will be available in a generic form and will also know what their appropriate return type is (in this case it would probably go off the

[sqlalchemy] Type of calculated columns

2007-11-30 Thread Mike Orr
I have a calculated column that takes the first non-NULL value among three dates. It should remain a datetime object but instead it's being converted to a string. Is it possible to tell SQLAlchemy to treat this value like a DateTime column? # Table t_incident defined with sa.Column("last_en

[sqlalchemy] Re: concurent modification

2007-11-30 Thread imgrey
> one immediate flaw I see in your application is that you are using > implicit execution of SQL constructs without them having any > connection to the ongoing transaction, such as: > > f_table.delete(f_table.c.user_id==theone.id).execute() > f_table.insert().execute(user_id=theone.id, path='/', l

[sqlalchemy] Re: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson
Yep, it seems that this was just 0.4.0 getting confused about my redundant relationships. It's working now. Thanks for actually looking at my code. On Nov 30, 4:36 pm, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > I just updated to sqlalchemy 0.4.1, and see the error. I'll remove the > duplicat

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-11-30 Thread Michael Bayer
1.2.2 over here produces regular "datetime" objects. On Nov 30, 5:45 pm, Samuel <[EMAIL PROTECTED]> wrote: > On Nov 30, 11:21 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > Row: > > > thats not a sqlalchemy DateTime object. are you on a very old version > > of MySQLdb ? > > Quite possibly

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-11-30 Thread Samuel
On Nov 30, 11:21 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > > Row: > > thats not a sqlalchemy DateTime object. are you on a very old version > of MySQLdb ? Quite possibly: >>> print MySQLdb.__version__ 0.9.2 >>> -Samuel --~--~-~--~~~---~--~~ You received t

[sqlalchemy] Re: ORM and (un)correlated subqueries

2007-11-30 Thread Michael Bayer
if you're trying to prevent tables in your subqueries from correlating outwards, issue correlate(None) on the subqueries themselves. On Nov 30, 5:12 pm, kris <[EMAIL PROTECTED]> wrote: > I have a filter expression 'e' with subqueries embedded. > > I would like issues a query > such as session.q

[sqlalchemy] Re: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson
I just updated to sqlalchemy 0.4.1, and see the error. I'll remove the duplicate relations, and see if that clears this up. On Nov 30, 4:30 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Nov 30, 5:18 pm, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > > > I'm on SA 0.4.0 > > > I was under the i

[sqlalchemy] Re: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Michael Bayer
On Nov 30, 5:18 pm, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > I'm on SA 0.4.0 > > I was under the impression that you had to declare the relationship > from both sides, and that backref was only used to update related > objects when one side of the relation was changed. Can you point me to

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-11-30 Thread Michael Bayer
On Nov 30, 4:59 pm, Samuel <[EMAIL PROTECTED]> wrote: > On Nov 30, 10:15 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > a DateTime, meaning a sqlalchemy.types.DateTime ? > > Yes. (sqlalchemy 0.3) > > > thats not a date- > > holding object, its a TypeEngine object which describes a date-hold

[sqlalchemy] Re: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson
I'm on SA 0.4.0 I was under the impression that you had to declare the relationship from both sides, and that backref was only used to update related objects when one side of the relation was changed. Can you point me to some docs for this? ~jon On Nov 30, 3:26 pm, Michael Bayer <[EMAIL PROTECT

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-11-30 Thread Samuel
On Nov 30, 10:15 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > a DateTime, meaning a sqlalchemy.types.DateTime ? Yes. (sqlalchemy 0.3) > thats not a date- > holding object, its a TypeEngine object which describes a date-holding > database column. from the code sample below I dont see how that

[sqlalchemy] ORM and (un)correlated subqueries

2007-11-30 Thread kris
I have a filter expression 'e' with subqueries embedded. I would like issues a query such as session.query(Ty).filter (e).correlate (None) I tried this but it failed as correlate only works directly on select statements, Does anybody know how to pass this through or how to rewrite it? --~--~

[sqlalchemy] Re: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Michael Bayer
On Nov 30, 2007, at 3:26 PM, Jonathon Anderson wrote: > > I'm seeing (seemingly random) instances of sqlalchemy not returning an > object for a relation. It seems to think that the "_id" > column is None. > > The code in question is available at > http://trac.mcs.anl.gov/projects/clusterbank/bro

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-11-30 Thread Michael Bayer
hi Samuel - a DateTime, meaning a sqlalchemy.types.DateTime ? thats not a date- holding object, its a TypeEngine object which describes a date-holding database column. from the code sample below I dont see how that could be returned since res.fetchone().changed would be the actual contents

[sqlalchemy] Re: concurent modification

2007-11-30 Thread Michael Bayer
On Nov 30, 2007, at 3:06 PM, imgrey wrote: > > > On 30 нояб, 21:07, Michael Bayer <[EMAIL PROTECTED]> wrote: >> hey there - >> >> this is line 179 right now: >> >> if bind in conn_dict: >> >> similar mismatches in the stacktrace are present for lines 505 and >> 509 >> (line 505 is

[sqlalchemy] DateTime vs datetime.datetime

2007-11-30 Thread Samuel
Hi, I haven't found this in the list archives or the docs: How do you convert between DateTime and datetime.datetime objects? In particular, I am trying to do the following: last_change = res.fetchone().changed # this returns a DateTime object test = last_change < datetime.datetime.now() TypeE

[sqlalchemy] sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson
I'm seeing (seemingly random) instances of sqlalchemy not returning an object for a relation. It seems to think that the "_id" column is None. The code in question is available at http://trac.mcs.anl.gov/projects/clusterbank/browser/trunk/source/packages/clusterbank/model Thanks in advance. ~jo

[sqlalchemy] Re: concurent modification

2007-11-30 Thread imgrey
On 30 нояб, 21:07, Michael Bayer <[EMAIL PROTECTED]> wrote: > hey there - > > this is line 179 right now: > > if bind in conn_dict: > > similar mismatches in the stacktrace are present for lines 505 and 509 > (line 505 is a blank line now). > > the full snip of code is: > >

[sqlalchemy] Re: concurent modification

2007-11-30 Thread Michael Bayer
hey there - this is line 179 right now: if bind in conn_dict: similar mismatches in the stacktrace are present for lines 505 and 509 (line 505 is a blank line now). the full snip of code is: if bind in conn_dict: (conn, trans, autoclose) = conn_dic

[sqlalchemy] Re: concurent modification

2007-11-30 Thread imgrey
> i think its impossible for you to be getting the same stacktrace that > you were, can you post what youre getting now please... Exception in thread Thread-6: Traceback (most recent call last): File "threading.py", line 442, in __bootstrap self.run() File "./camper.py", line 104, in run

[sqlalchemy] Re: concurent modification

2007-11-30 Thread Michael Bayer
On Nov 30, 2007, at 9:36 AM, imgrey wrote: > >> based on your stacktrace, here's your bug, fixed in r3839: > > cannot understand how this is working i think its impossible for you to be getting the same stacktrace that you were, can you post what youre getting now please... --~--~-

[sqlalchemy] Re: concurent modification

2007-11-30 Thread imgrey
> based on your stacktrace, here's your bug, fixed in r3839: cannot understand how this is working > > from sqlalchemy import * > from sqlalchemy.orm import * > > session = scoped_session(sessionmaker(transactional=True, > autoflush=False)) > > engine = create_engine('postgres://scott:[EMAIL PRO