MySQLdb and column names

geoffrey907 at geoffrey907 at
Mon Sep 18 23:18:53 CEST 2000

Am currently working on building a little data
migratation tool using python.  This script is my
first real foray into the realm of python, and
with some help for several kind people in
comp.lang.python I've actually managed to build a
working tool that migrates data from one MySQL
database to another.  The two databases have a
number of _similar_ tables.  About half them are
exactly the same execpt for differing column

For this group of tables I would like to build a
function builds the necessary input statement from
the the table w/out my help.  Here's more or less
what I'm trying to do:


def transferData(oldTable, newTable):
  sql = "SELECT * FROM %s" % oldTable
  for row in cur.fetchall():
    sql = """
      INSERT INTO %s
      VALUES %s
    """ % (newTable, str(whatHere?), str(row))


...where curNew and curOld are the names of the
cursors corrisponding to my old and new databases,
where oldTable is the name of the originating
table and newTable is the name of the target table
for the INSERT statment.  The problem is that the
I don't know what I can do to get a list of column
names for my target database.  Any hints for
getting this done?

Many thanks,


Sent via
Before you buy.

More information about the Python-list mailing list