[DB-SIG] create table in win32 odbc module

David Brydon brydon@claborn.net
Mon, 17 Apr 2000 22:52:28 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_002B_01BFA8BF.9B068960
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello.=20
    I have gotten a lot of use from the wonderful odbc module in the =
win32 distribution of Mark Hammond.  But the last few days I have been =
stumped.
   I am running on Windows NT 4.0, talking to MS SQL Server.  I can =
access existing data fine, but am having trouble creating a table from =
the python.  Can anyone help?
The same code run as sql in the database makes the table.  The python =
script says the table exists if you try to create it twice.  No errors =
are given.  But the table never appears in the MS SQL Enterprise Manager =
or Query Analyzer.
My code looks like:
import dbi, odbc # needed to connect to database
db =3D odbc.odbc('TSQL/SA/') # get the database connection
cursor =3D db.cursor(DBLogin)  # start a cursor
sql =3D "create table TestTemp (name text)"
print sql
print ' '
cursor.execute(sql)       =20
sql=3D"insert into TestTemp (name) values ('12345')"
print sql
print ' '
cursor.execute(sql)       =20
cursor.close()
db.close()

cursor =3D None
db =3D None=20

No errors, but no table after it runs!  Thanks much, David

------=_NextPart_000_002B_01BFA8BF.9B068960
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hello.&nbsp;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; I have gotten a lot of use from =
the=20
wonderful odbc module in the win32 distribution of Mark Hammond.&nbsp; =
But the=20
last few days I have been stumped.</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; I am running on Windows NT 4.0, talking =
to MS SQL=20
Server.&nbsp; I can access existing data fine, but am having trouble =
creating a=20
table from the python.&nbsp; Can anyone help?</FONT></DIV>
<DIV><FONT size=3D2>The same code run as sql in the database makes the=20
table.&nbsp; The python script says the table exists if you try to =
create it=20
twice.&nbsp; No errors are given.&nbsp; But the table never appears in =
the MS=20
SQL Enterprise Manager or Query Analyzer.</FONT></DIV>
<DIV><FONT size=3D2>My code looks like:</FONT></DIV>
<DIV><FONT size=3D2>import dbi, odbc # needed to connect to =
database<BR>db =3D=20
odbc.odbc('TSQL/SA/') # get the database connection</FONT></DIV>
<DIV><FONT size=3D2>cursor =3D db.cursor(DBLogin)&nbsp; # start a =
cursor<BR>sql =3D=20
"create table TestTemp (name text)"<BR>print sql<BR>print '=20
'<BR>cursor.execute(sql)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>sql=3D"insert into TestTemp (name) values ('12345')"<BR>print =
sql<BR>print '=20
'<BR>cursor.execute(sql)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>cursor.close()<BR>db.close()</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>cursor =3D None<BR>db =3D None </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>No errors, but no table after it runs!&nbsp; Thanks =
much,=20
David</FONT></DIV></BODY></HTML>

------=_NextPart_000_002B_01BFA8BF.9B068960--