I am trying to upload a large csv file to a MySQL server. I am testing this with only one row. However, when I run my code, the command that is being sent to the server is correct, but when I check in mySQL workbench if the row has been added, it isn't there. I'm not sure what the issue is. Anything you can do to help would be much appreciated.
Here is my code:
import csv
import mysql.connector
def uploadfile():
file2 = open("./jan.csv", 'r')
csvreader2 = csv.reader(file2)
csvreader2.__next__()
return csvreader2
reader = uploadfile()
cnx = mysql.connector.connect(CORRECT INFO, HIDDEN FOR PRIVACY )
cursor = cnx.cursor()
i = 0
values = "', '".join(reader.__next__())
command = "insert into AllW (station, valid, lon, lat, tmpf, dwpf, relh, drct, sknt, p01i, alti, mslp, " \
"vsby, gust, skyc1, skyc2, skyc3, skyc4, skyl1, skyl2,skyl3, skyl4, wxcodes, ice_accretion_1hr," \
" ice_accretion_3hr, ice_accretion_6hr, peak_wind_gust, peak_wind_drct, peak_wind_time, feel, " \
"metar, snowdepth) values ('" + values + "')"
cursor.execute(command)
print(cursor.statement)