Python and ODBC
Steve Holden
sholden at holdenweb.com
Thu May 2 16:27:54 EDT 2002
"Uwe Schmitt" <uwe at rocksport.de> wrote in message
news:aarrir$b5ub4$1 at hades.rz.uni-sb.de...
> "Bruno Liénard" <lienard.bruno at free.fr> wrote:
> | Maybe a stupid question, but how can we create table with python and
ODBC,
> | mxODBC for example. I have looked to the doc, but I didn't see anyfind
about
> | it.
>
> i think thats a sql question...
>
Untested code warning. First you need to create an ODBC data source that
mxODBC can access. I assume it is called "mydb".
import mxODBC as db
conn = db.connect("mydb")
cursor = conn.cursor()
cursor.execute("""CREATE TABLE tbl (
field1 INTEGER PRIMARY KEY,
field2 VARCHAR(20))""")
# remove next line if autocommit in operation
conn.commit()
conn.close()
I think that's about it.
regards
Steve
--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/
More information about the Python-list
mailing list