help - inserting values into database tables

chajadan python at chajadan.net
Sun Feb 17 19:47:09 EST 2002


Yes, this is altogether possible.

There is a module include in the main distribution called odbc, and one 
called dbi.

You can look into the modules documentation for the details.

But basically, do something like this:

import dbi
import obdc

conn = odbc.odbc("dsn")
rs = conn.cursor()
rs.execute("insert into " + table + " values ('" + charval1 + "', " + 
numval1 + ")")
rs.close
conn.close


 From what I heard, dbi should always be imported prior to obdc. The conn 
string takes a dns name as a string--it's easier to use system dsns for 
this, but I think there is a way around that to use file dsns if you must.

There are other oddities; but all in all this should get you started.

--chajadan

At 06:00 PM 2/17/02 +0000, mylinuxboxroot wrote:

>Hey all,
>
>Ok I am wondering something:
>I have a python list which has values I would like to insert into a
>database, the
>database is a microsoft (ugh)  Access type of database.
>-- I don't know much about the python for windows side of things like
>ODBC
>----Is this type of thing possible ????????????
>
>What are some basic things I need to know about this problem space???
>Where shall I look (on the web) for guideance for this type of thing ???
>
>Basically the MS - Access database tables do exist and I want to insert
>    info from my python list into it.  But I have no clue if this can be
>done.
>    Can I connect to the MS - Access database with a python script to
>     insert my list into the database ??????????
>
>Thanks,
>Joe F.
>-----
>
>--
>http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list