[DB-SIG] create table in win32 odbc module
Sam Gendler
sgendler@silcom.com
Mon, 17 Apr 2000 21:44:59 -0700
I don't use ODBC, but just here's a guess. 'cursor.commit()'
> David Brydon wrote:
>
> Hello.
> 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 = odbc.odbc('TSQL/SA/') # get the database connection
> cursor = db.cursor(DBLogin) # start a cursor
> sql = "create table TestTemp (name text)"
> print sql
> print ' '
> cursor.execute(sql)
> sql="insert into TestTemp (name) values ('12345')"
> print sql
> print ' '
> cursor.execute(sql)
> cursor.close()
> db.close()
>
> cursor = None
> db = None
>
> No errors, but no table after it runs! Thanks much, David