On Thursday 07 February 2008, Enis Karaarslan wrote:
> Hello all,
>
> I am a newbie in PyQt, just a simple question.
> I want to use a variable in my sql tatement.
>
> If I use string, following statment runs smoothly
>
> db.query("""SELECT OS, IP_Adress
> FROM ServerDB
> WHERE IP_Adresi='10.22.5.1'""")
> s = db.store_result()
>
>
> But I want to use the variable "chosen" and get the IP_Adresses equal to
> that variable such as:
>
> db.query("""
>                       SELECT OS, IP_Adress
>                       FROM ServerDB
>                       WHERE IP_Adress = chosen
>                       """)
>
> But it doesn't work ...
>
> thanks for the help

Dynamically create the string you want...

db.query("""
                        SELECT OS, IP_Adress
                        FROM ServerDB
                        WHERE IP_Adress = '%s'
                        """ % chosen)

Phil
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to