suppose:

    summary_table = Table(
        'summary', metadata,
        Column('ts',Integer, index=True, nullable=False),
        Column('url',String, index=True, nullable=False),
        Column('hits',Integer, nullable=False),
        PrimaryKeyConstraint('ts','url','hits',name='summary_pk'),
    )

And a query like:

    s = summary_table.c
    q =  select([
        s.url,
        s.ts,
    ]).\
    where(s.site == bindparam("url")).\
    where(s.ts == bindparam("ts")


* how to 'copy' a query.  copy.copy(q) seems to be inadequate
* how to print it, with params filled in.  str(q) isn't quite enough.
  (I know this has been covered before, but I can't seem to find it,
and
  if it's not in the docs, it should be!).  The query is bound to an
  engine already.  My desired goal is to see the actual sql (with
  filled quoted params) that would get sent to the engine.  If I had
  this, I could always just use a regex to change the table.
* how to change the table being called.  My specific subcase is for an
inherited
  table.  I tried this, but it seems very dirty:

  q._froms[0].name = 'summary_1279234800'

  Is there a general method for that I should use?  (Also, this will
be fine
  if I can get the 'copy' business to work.

As usual, SA is great, and I'm doing rude, mean things to it, so if
there are simpler ways out of this mess (wanting simple query
construction,
but one that I can alter to use on specific Postgres INHERIT tables),
please
inform me.

-- 
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...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to