Open
Description
To insert mutliple values at once there is the sqlc copyfrom, but it it is unsupported in sqlc-gen-python
But it should be quite easy to implement using an executemany
statement:
https://stackoverflow.com/questions/13020908/sql-multiple-inserts-with-python
rows = []
for row in range(sheet.nrows):
"""name is in the 0th col. email is the 4th col."""
name = sheet.cell(row, 0).value
email = sheet.cell(row, 4).value
rows.append((name, email))
db = MySQLdb.connect(host=host, user=user, db=dbname, passwd=pwd)
cursor = db.cursor()
cursor.executemany("""INSERT INTO mailing_list (name,email) VALUES (%s,%s)""", rows)
Metadata
Metadata
Assignees
Labels
No labels