[python-sybase] problems with executing dynamically created
queries.
Erik Thiele
erik at thiele-hydraulik.de
Fri, 23 Jul 2004 15:37:56 +0200
On Wed, 21 Jul 2004 17:04:45 +0200
Erik Thiele <erik@thiele-hydraulik.de> wrote:
> 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?
hmmmm. still i have no working example.
there is this python-sybase module and i cannot get it to work. there
must be something wrong here. Could you give me a query that runs on the
above configuration? i want to create the query dynamically. i.e. no
static query, but instead some query like the one above.
is the python-sybase module broken?
--
Erik Thiele