Getting started with mysqldb
Geoffrey L. Wright
geoff.nospam at northernwastes.org
Fri Sep 15 22:07:11 EDT 2000
So in a burst of enthusiasm born of my new found interest in python,
I've decided to use it to write a few SQL data-loaders for a project
I'm working on. After only a little bit of a struggle I've
(seemingly) managed to get the MySQLdb module compliled and correctly
located on a RH6.2 box running MySQL MySQL-3.23.23. After looking
though some examples, I've managed to write a simple script that
displays results from my database. So far so good.
But now (just to prove that I can) I want to take the all the records
from one table and insert them in an identictly structured test table.
But I'm stuck, because I can't seem to concatenate what I _think_ are
two strings.
Here's the the relevent code:
for row in sel_radgroupreply:
currentRow = row
q_ins_radgroupreply = "INSERT INTO test_radgroupreply (id
GroupName, Attribute, Value) VALUES %s" % currentRow
print q_ins_radgroupreply
But I get "TypeError: not all arguments converted". I'm guessing that
the value of currentRow is not a string, but I'm _very_ new to both
python, and I don't see another obvious way to do this. Any hints?
Note that if do a "print row" in my loop, that I can see everything in
the table so the rest of my code seems to be fine. Would also be
happy for any recomendations for good python/MySQL reading material.
Thanks!
//glw
More information about the Python-list
mailing list