Thank you for such a prompt response.

Per the excellent documentation I added the following four lines to
my .py script:

  import logging

  logging.basicConfig()
  logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
  logging.getLogger('sqlalchemy.orm.unitofwork').setLevel
(logging.DEBUG)

And received the following log output:

INFO:sqlalchemy.engine.base.Engine.0x...0350:
            SELECT a.attname,
              pg_catalog.format_type(a.atttypid, a.atttypmod),
              (SELECT substring(d.adsrc for 128) FROM
pg_catalog.pg_attrdef d
               WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND
a.atthasdef)
              AS DEFAULT,
              a.attnotnull, a.attnum, a.attrelid as table_oid
            FROM pg_catalog.pg_attribute a
            WHERE a.attrelid = (
                SELECT c.oid
                FROM pg_catalog.pg_class c
                     LEFT JOIN pg_catalog.pg_namespace n ON n.oid =
c.relnamespace
                     WHERE (pg_catalog.pg_table_is_visible(c.oid))
                     AND c.relname = %(table_name)s AND c.relkind in
('r','v')
            ) AND a.attnum > 0 AND NOT a.attisdropped
            ORDER BY a.attnum

INFO:sqlalchemy.engine.base.Engine.0x...0350:{'table_name':
'products'}
INFO:sqlalchemy.engine.base.Engine.0x...0350:
            SELECT t.typname as "name",
                   pg_catalog.format_type(t.typbasetype, t.typtypmod)
as "attype",
                   not t.typnotnull as "nullable",
                   t.typdefault as "default",
                   pg_catalog.pg_type_is_visible(t.oid) as "visible",
                   n.nspname as "schema"
            FROM pg_catalog.pg_type t
                 LEFT JOIN pg_catalog.pg_namespace n ON n.oid =
t.typnamespace
                 LEFT JOIN pg_catalog.pg_constraint r ON t.oid =
r.contypid
            WHERE t.typtype = 'd'

INFO:sqlalchemy.engine.base.Engine.0x...0350:{}
INFO:sqlalchemy.engine.base.Engine.0x...0350:
          SELECT attname FROM pg_attribute
          WHERE attrelid = (
             SELECT indexrelid FROM pg_index i
             WHERE i.indrelid = %(table)s
             AND i.indisprimary = 't')
          ORDER BY attnum

INFO:sqlalchemy.engine.base.Engine.0x...0350:{'table': 16726}
INFO:sqlalchemy.engine.base.Engine.0x...0350:
          SELECT conname, pg_catalog.pg_get_constraintdef(oid, true)
as condef
          FROM  pg_catalog.pg_constraint r
          WHERE r.conrelid = %(table)s AND r.contype = 'f'
          ORDER BY 1

INFO:sqlalchemy.engine.base.Engine.0x...0350:{'table': 16726}
INFO:sqlalchemy.engine.base.Engine.0x...0350:UPDATE products SET title=
%(title)s WHERE products.name = %(name_1)s
INFO:sqlalchemy.engine.base.Engine.0x...0350:{'title':
'updated_title', 'name_1': 'test'}
INFO:sqlalchemy.engine.base.Engine.0x...0350:COMMIT



On Jan 14, 7:36 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> that should be fine, what does your log output say ?
>
> On Jan 14, 2009, at 12:38 AM, atomburner wrote:
>
>
>
> > Mr. Bayer, you know entirely too much about all kinds of databases.
>
> > A follow-up question to your erudite comment (and let me first say
> > that I love sqlalchemy and have spent a good amount of time immersed
> > in its documentation before posting):
>
> > I tried running an update query of the form
>
> >  conn.execute(tbl.update().where(tbl.c.name=='test').values
> > (title='updated_title'))
>
> > FWIW the column was setup as follows (in PostgreSQL 8.2):
>
> >  Column('updated', DateTime,onupdate=func.now())
>
> > After running above code and requerying the db, the 'updated' column
> > is still null.
>
> > I also tried using func.current_timestamp() with no luck.
>
> > Any tips you are able to provide are greatly appreciated.
>
> > Best regards,
> > Atom
>
> > On Dec 6 2008, 6:48 am, Michael Bayer <mike...@zzzcomputing.com>
> > wrote:
> >> that is the correct syntax.  It will take effect any time an update()
> >> construct is used or when the ORM updates a row.   Becauseonupdateis
> >> not aDDL-side construct, it will not take effect if you use a plain
> >> text UPDATE statement or if the update is otherwise not emitted by  
> >> the
> >> SQLAlchemy application.   The PassiveDefault, since it does represent
> >>DDL, will work in this manner, but only if the table was created  
> >> using
> >> this table construct.
>
> >> On Dec 6, 2008, at 4:50 AM, jo wrote:
>
> >>> Hi all,
>
> >>> I created a table with the following column:
>
> >>> Column('last_updated', DateTime,  
> >>> PassiveDefault(func.current_timestamp
> >>> ()),onupdate=func.current_timestamp())
>
> >>> Maybe I don't understand howonupdateworks.
> >>> I would like to have this column to be changed every time the row is
> >>> updated,
> >>> but it doesn't work.
>
> >>> thank you for any help
>
> >>> j
>
>
--~--~---------~--~----~------------~-------~--~----~
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 options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to