Insert database rows from CSV file

3c273 nospam at nospam.com
Tue Apr 5 10:40:43 EDT 2005


"Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
news:bp2451l8psd6qnid15jpmv0ooipqsl95b0 at 4ax.com...
> On Mon, 4 Apr 2005 15:54:37 -0700, "3c273" <nospam at nospam.com> declaimed
> the following in comp.lang.python:
>
> > Thanks for the link, but this is the step I am trying to save (for
someone
> > else). Every time he goes to run a report, he must stop and import any
new
> > csv files. Since the files are generated by a Python script, I thought I
>
> That information wasn't supplied in the original message. Your
> original post implied that the data source /was/ the CSV file...
>
> Show us the code segment that is writing the CSV file, and we
> can probably show you the DB-API equivalent for "writing" a new record
> to the table.
>
> For short however:
>
> aCustomer = "Customer1"
> theWidget = "Widget1"
> aQuantity = 1000
>
> # I'm presuming the table only has the three columns, since you didn't
> list fields
> cursor.execute(""" INSERT INTO "Table1" Values (%s, %s, %s) """,
> (aCustomer, theWidget, aQuantity))

Ah.. Many thanks. This is what I was looking for.
Louis





More information about the Python-list mailing list