[Tutor] Python variable in SQL statement
Sharriff Aina
NHYTRO@compuserve.com
Wed, 11 Apr 2001 04:54:37 -0400
Message text written by INTERNET:tutor@python.org
><
I=B4m trying to generate dynamic web pages by reading chunks of HTML from=
a
database, my prob is, my SQL statements using the Python ODBC module does=
not recognize my python container:
###### my code ##
print "Content-Type: text/html\n\n"
import cgi, dbi, odbc, time
#
#
# my HTML container
#
template0 =3D """
<html>
<head><title>blah</title></head>
<body>
adkasdkadkadjakdjakdjakdjadjada, adadadad
dadadadada,dadadad
dadadad
adada
dad
adada
adad
<body>
<html>
"""
#database access
connection =3D odbc.odbc('minicms')
cur =3D connection.cursor()
cur.execute('select * from dummy')
for a in range(3):
cur.execute("insert into dummy(fieldtwo, fieldthree) values('foonav',=
template0)")
connection.commit()
cur.close()
connection.close()
###### end code ###
The ODBC driver states that only one value has been given, it just
overlooks the "template0" big string container that I declared.
Thanks for your anticipated help in advance
Sharriff