im sorry this is giving you so much trouble...people usually dont ask
about this since if they want to work with the bind parameters directly
they usually use the bindparam() construct explicitly.
this script will illustrate everything about the bind params:
from sqlalchemy import *
# create metadata using engine with mysql dialect
meta = BoundMetaData('mysql://')
t = Table( 'test', meta, Column('col1', Integer), Column('col2',
Integer))
# select statement
s = t.select( t.c.col1 == 'somevalue' )
# whereclause, in this case is a Boolean Expression
print repr(s.whereclause)
# string representation of whereclause, note it uses %s for the bind
# param because the column "col1" is attached to "t" which loads in
# the MySQL dialect which indicates the "format" paramstyle
print s.whereclause
# bind parameter by itself, doesnt know about MySQL dialect, so
# defaults to :test_col1
print s.whereclause.right
# bind parameter is an instance of _BindParamClause
print repr(s.whereclause.right)
# key, value of the BindParamClause:
print s.whereclause.right.key, s.whereclause.right.value
# locate all binds in the select using the "visitor" interface
class MyVisitor(ClauseVisitor):
def visit_bindparam(self, bindparam):
print bindparam.key, bindparam.value
s.accept_visitor(MyVisitor())
# full dictionary of binds also calulcated by the compile step
# this dict is an instance of sql.ClauseParameters which has some
# extra functionality
print s.compile().get_params()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---