이것은 내가 본 중에 가장 도움이되는 오류는 아니지만 Google에서 오류를 발생시키는 타이핑 오류 인 것처럼 보이지만 그 사실을 알 수 없습니다. 나는 그 명백한 것을 놓치고 있습니까?python mysql error <class '_mysql_exceptions.ProgrammingError'>
# Prepare SQL query to INSERT a record into the database.
sql = "INSERT INTO spin_hdd(error_count, raw_read_error, spin_up_time, allo_sec, seek_error, spin_retry, gsense_error, power_on_hours, pending_sector, load_retry, spin_up_time, max_temp, sector_count, short_test_time, long_test_time, model, serial, firmware, ip, running) \
VALUES ('%s','%s','%s','%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % \
(error_count, raw_read_error, spin_up_time, allo_sec, seek_error, spin_retry, gsense, power_on, pend_sec, load_retry, spin_up_time, max_temp, sector_count, testShortTime, testLongTime, model_count, serial, firmware, ip, 1)
try:
# Execute the SQL command
cur.execute(sql)
# Commit your changes in the database
con.commit()
# get last inserted id
id = cur.lastrowid
except:
# Rollback in case there is any error
con.rollback()
e = sys.exc_info()[0]
print e
마지막 열의 유형이 정수형 인 경우'% s '주변에서'''을 제거해야합니다. –
또한 데이터 형식이 'int'일 수있는 많은 열이 있습니다. 컬럼 이름에서 추측하고 있습니다. 이런 경우, 모든 컬럼에서'''를 제거해야합니다. –