[sqlalchemy] simple: get max id in table

2018-04-24 Thread Steve Murphy
I'm just not getting it: Want: select max(id) from table; attempt (latest): from sqlalchemy import * from sqlalchemy.engine import reflection from sqlalchemy import schema from sqlalchemy import exc from psycopg2 import * import re import time import os targethost = "192.168.181.204" targetdb

Re: [sqlalchemy] Tips for schema based db traversal and building

2015-09-30 Thread Steve Murphy
See below On Tuesday, September 8, 2015 at 9:00:12 PM UTC-4, Michael Bayer wrote: > > > > you can get these like this: > > from sqlalchemy import inspect > insp = inspect(my_engine) > > fk_constraints = insp.get_foreign_keys('mytable') > uq_constraints = insp.get_unique_constraints('mytable') >

Re: [sqlalchemy] Tips for schema based db traversal and building

2015-09-30 Thread Steve Murphy
On Wednesday, September 30, 2015 at 1:43:46 PM UTC-6, Michael Bayer wrote: > > there's no known bugs in fetching unique constraints. PG 8.4 is a pretty > old version but should be working. > > note that a unique index and a unique constraint aren't listed as the same > thing, however.you

Re: [sqlalchemy] Tips for schema based db traversal and building

2015-09-09 Thread Steve Murphy
Oh, Michael! You have made my day. It just gets better and better! I don't know how I missed these items, but your examples are very helpful. Many thanks! On Tuesday, September 8, 2015 at 7:00:12 PM UTC-6, Michael Bayer wrote: > > > > On 9/8/15 12:57 PM, Steve Murphy wrote:

[sqlalchemy] Tips for schema based db traversal and building

2015-09-08 Thread Steve Murphy
This message concerns using sqlAlchemy for schema based traversal and manipulation. It is the result of a project to transfer data from on database to another, where objects refer to each other, and must be copied to new rows in the target db, and have all the foreign references updated in

Re: [sqlalchemy] Why is an association object mark as dirty instead of deleted when removed?

2015-05-06 Thread steve
Hmm, I don't think I could listen to the attribute event; it's saying that the AssociationProxy doesn't have dispatch. Also, suppose I could detect the orphan-deletes earlier, what's the best way to suppress the objects marked as dirty? Here's my version of your code if it helps:

Re: [sqlalchemy] Why is an association object mark as dirty instead of deleted when removed?

2015-04-29 Thread steve
Since my association object doesn't have extra columns, the row ('bob, 'apple') will be deleted. However, if there are extra columns, then having it marked as dirty is desired. Perhaps I would delay my recording of my audit rows until after orphans are resolved. I am already using after_flush,

[sqlalchemy] Why is an association object mark as dirty instead of deleted when removed?

2015-04-28 Thread steve
, it marks the UserKeyword association object is dirty instead of deleted. Why is that? Since the row is being removed, I would expect it to be marked as deleted, so that I could make an audit record indicating it was deleted. Thanks, Steve -- You received this message because you

Is Firebird supported?

2015-03-17 Thread Steve
, in get_by_dialect return _impls[dialect.name] KeyError: 'firebird' Thanks, Steve -- You received this message because you are subscribed to the Google Groups sqlalchemy-alembic group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr

Re: [sqlalchemy] Re: How to stop SQLAlchemy from adding an ON UPDATE clause to a TIMESTAMP column by default

2014-01-10 Thread Steve Johnson
I realize this thread is ancient, but I'm resurrecting it for Googleable posterity since I just ran across the same issue. The problem is that MySQL helpfully inserts the ON UPDATE cheese unless you specify a default and/or a NULL/NOT NULL value in the CREATE TABLE query.

Re: [sqlalchemy] Re: How to stop SQLAlchemy from adding an ON UPDATE clause to a TIMESTAMP column by default

2014-01-10 Thread Steve Johnson
My solution, since sqlalchemy seems to be ignoring the nullable and default kwargs, is this: time = Column( TIMESTAMP(), primary_key=True, server_default=text('-00-00 00:00:00')) The default is just never used. On Friday, January 10, 2014 12:20:45 PM UTC-8, Steve

Re: [sqlalchemy] Getting comparison TypeError when trying to commit aware datetime when previous value was naive datetime

2012-05-13 Thread Steve Zatz
you should only be dealing with timezone-naive datetimes within a Python application Thanks - make sense although the klugey way around the problem is just to commit None before you change between naive and aware since comparisons with None are fine. -- You received this message because you are

[sqlalchemy] Getting comparison TypeError when trying to commit aware datetime when previous value was naive datetime

2012-05-12 Thread Steve Zatz
When I try to commit a timezone aware datetime to replace a value that was previously timezone naive, I get a TypeError when I try to do the commit with the message: TypeError: can't compare offset-naive and offset-aware datetimes Now I am not trying to compare anything but just store the new

[sqlalchemy] Re: Joining three tables - Selecting column from two different tables

2011-01-20 Thread Steve
Hi, Thanks. Worked like a charm. Also thanks for SqlAlchemy. A refreshing change for someone from java background. I am using this with Jython. Thanks for the Jython support also. Steve On Jan 18, 8:54 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 18, 2011, at 9:11 AM, Steve wrote

[sqlalchemy] Joining three tables - Selecting column from two different tables

2011-01-18 Thread Steve
).\ all() Thanks in advance. Steve. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more

[sqlalchemy] Re: Determine what joins are in select statement

2009-11-01 Thread Steve Zatz
? Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr

[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
)? Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr

[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
(). [It was missing in the most recent example but apparently an empty dictionary is fine.] Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy

[sqlalchemy] Re: Determine what joins are in select statement

2009-10-28 Thread Steve Zatz
use query.statement to get at the SQL expression Thanks. That worked. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe

[sqlalchemy] many-to-one question on delete

2009-09-14 Thread Steve Zatz
to a context_id = 0. Thanks for any advice. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group

[sqlalchemy] Re: many-to-one question on delete

2009-09-14 Thread Steve Zatz
. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr

[sqlalchemy] LIKE filter and psycopg2

2008-11-12 Thread Steve Howe
should I be doing ? Use another syntax ? Replace psycopg2's paramstyle to non-escaping mode ? My environment: Python 2.5.2 SQLAlchemy 0.5.0.rc3 PostgreSQL 8.30 psycopg 2.0.7 Ubuntu 8.04 -- Best Regards, Steve Howe --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: LIKE filter and psycopg2

2008-11-12 Thread Steve Howe
- that confused me. It's working now, thanks, I needed the ILIKE function. -- Best Regards, Steve Howe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy

[sqlalchemy] adding a child to 2 parents, 2 ways

2008-10-22 Thread Steve Harris
? Is this the way it should be? -Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL

[sqlalchemy] Re: adding a child to 2 parents, 2 ways

2008-10-22 Thread Steve Harris
Thanks for the explanation, Michael. The behavior is very sensible now that I see what's happening. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: trunk is now on 0.5

2008-05-10 Thread Steve Zatz
Trunk Rev 4726 Note the following: Python 2.5.2 (r252:60911, May 7 2008, 15:19:09) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type help, copyright, credits or license for more information. from sqlalchemy import * Traceback (most recent call last): File stdin, line 1, in module File

[sqlalchemy] Re: trunk is now on 0.5

2008-05-10 Thread Steve Zatz
be sure to clean out the .pyc files. That worked. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this

[sqlalchemy] Re: Mapper issue with r4485

2008-04-11 Thread Steve Zatz
my hat's off to you for coming up with that relation(), it works again in rev 4486. Ah the irony ... check out http://tinyurl.com/6kqv94 And thanks as always for your remarkable responsiveness and for sqlalchemy. It is indispensible. Steve

[sqlalchemy] Re: self-referential table question

2008-01-28 Thread Steve Zatz
Michael, Works perfectly. Thanks much. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send

[sqlalchemy] Re: self-referential table question

2008-01-28 Thread Steve Zatz
another option is: .query(Node).filter(not_(Node.id.in_(select([Node.parent_id] jason, thanks for the alternative method. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] self-referential table question

2008-01-27 Thread Steve Zatz
is. Any help would be appreciated. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email

[sqlalchemy] create indexes on function

2007-04-16 Thread Steve Huffman
Is it possible to create indexes using a function using sqlalchemy and postgresql? Something like: create index idx on table (lower(table.field)) Thanks, Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: Issue using rev 2425

2007-03-20 Thread Steve Zatz
Michael, thanks for working through this and for taking the time to explain what's going on and to provide alternative ways to getting this done. Your efforts to support the users of sqlalchemy are really extraordinary. --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Re: server_side_cursors

2007-03-17 Thread Steve Huffman
I may be missing something fundamental here, but why doesn't it already know the metadata since I defined the columns in which I'm interested? thing_table = sa.Table(thing, md, sa.Column('id', sa.Integer, primary_key = True)) On 3/17/07, Michael Bayer [EMAIL PROTECTED] wrote: the cursor

[sqlalchemy] Re: server_side_cursors

2007-03-17 Thread Steve Huffman
, then everyone can just upgrade. which version are you using? On Mar 17, 2007, at 8:41 PM, Steve Huffman wrote: I may be missing something fundamental here, but why doesn't it already know the metadata since I defined the columns in which I'm interested? thing_table = sa.Table(thing

[sqlalchemy] Re: self-referential table question

2006-12-02 Thread Steve Zatz
Works perfectly. Your responsiveness and the usefulness of SQLAlchemy continue to amaze. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: self-referential table question

2006-12-02 Thread Steve Zatz
Works. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For

[sqlalchemy] Problem with count in rev 2089

2006-11-09 Thread Steve Zatz
Prior to 2089, the following worked fine: session.query(ItemKeyword).count() where ItemKeyword has a compound primary key that is defined in its mapper as follows: mapper(ItemKeyword, itemkeyword_table, primary_key = [itemkeyword_table.c.item_uuid, itemkeyword_table.c.keyword_uuid],

[sqlalchemy] Re: Problem with mapper relationship when lazy=False

2006-10-23 Thread Steve Zatz
youre really looking to have an association object pattern here. I thought you might recommend that. My problem last time I tried an association object was that in the following situation: item table keyword table itemkeyword table (and association object) I couldn't get the keywords to eager

[sqlalchemy] Re: Problem with mapper relationship when lazy=False

2006-10-23 Thread Steve Zatz
the eager load should be able to go through the association object down to the endpoint Keyword objects Thanks -- that does work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this