





Я не понимаю вашего вопроса (что такое файлы? Какая у вас структура таблицы?), Но вот простой пример:
>>> import MySQLdb
>>> conn = MySQLdb.connect(host = "localhost",
user = "root",
password = "merlin",
db = "files")
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT * FROM files")
5L
>>> rows = cursor.fetchall()
>>> cursor.execute("CREATE TABLE destination (file varchar(255))")
0L
>>> for row in rows:
... cursor.execute("INSERT INTO destination VALUES (%s)" % row[0])
...
1L
1L
1L
1L
1L
Вот пример, предполагающий, что вы создали таблицу, в которую хотите перейти, с описательными именами:
>>> import MySQLdb
>>> conn = MySQLdb.connect(user='username', db='dbname')
>>> cur = conn.cursor()
>>> cur.execute('select files from old_table where conditions=met')
>>> a = cur.fetchall()
>>> for item in a:
... cur.execute('update new_table set new_field = %s' % item) # `item` should be tuple with one value, else use "(item,)" with comma
См. stackoverflow.com/questions/221533/…. Тот же вопрос. Другой день.