Help - Metadata variable passing parameters to DML queries

Deirdre Saoirse deirdre at deirdre.net
Wed Nov 8 20:13:15 EST 2000


mCursor.execute("select %s, %s, %s from %s where %s" % (mColumn1,
mColumn2, mColumn3, mFrom, mWhere))

I recommend double quotes as your where clause may need single quotes
around parts of it.

On Thu, 9 Nov 2000 arflores1 at earthlink.net wrote:

> Here's the sample code
> 
> mColumn1 = 'PK_ID'
> mColumn2 = 'Name'
> mColumn3 = 'Phone'
> mFrom = 'Person'
> mWhere = 'Email'
> 
> import dbi
> import odbc
> 
> What is the correct Select syntax coding for this stuff based on my 
> input variable defination.
> 
> mCursor.execute('Select %(mColumn1)s, %(mColumn2)s, %(mColumn3)s\
>                    From %(mFrom)s\
>                    Where %(mWhere)s')

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams





More information about the Python-list mailing list