[python-sybase] problems with executing dynamically created queries.

Erik Thiele erik at thiele-hydraulik.de
Wed, 21 Jul 2004 17:04:45 +0200


hi.

i am using 

- gentoo linux.
- sybase-0.36
- freetds-0.62.3
- python 2.3.3

from this linux machine i am accessing a mssql 7 server on an nt4.0 windows server.

i am doing

db=Sybase.connect('myserver','myuser','mypass','mydb')
c=db.cursor()
c.execute('select * from foo where something=@x', {'@x' : "blabla"})

it sais:

Sybase.DatabaseError: ------
Must declare the variable '@x'

??? i do not understand. why is this so?

i am trying to use python DB API 2.0. but i find the documentation for this
not very sufficient. there seems to be no good example at all on the net.

questions never covered and done wrong in almost all examples is the issue
with escaping the datatypes. some really do
c.execute("select from where x="%s"" % mystring)
this is of course fatal since mystring may contain closing " and then sql commands.

anyway... how do i get the module to work?


and... why is there several styles in DB API 2.0? i mean the Sybase.paramstyle
thing. i thought DB API was there for portability, and then i find out
that different modules have different ways to create sql queries. so there
is absolute zero portability. why?

thx & byebye
Erik


-- 
Erik Thiele