[MySQL] "Column count doesn't match value count at row 1"
Verfasst: Montag 17. Juni 2013, 20:38
Hallo alle zusammen, ich wollt mir ein Skript, schreiben das einfach random Datensätze Erstellt, wozu bracht man denn sowas fragt ihr euch:
Informatik abb 200+ gibts ne 1, mann könnte alles eingeben aber das dauert so lang
Tja leider Scheitert es schon am erstem Test
ja ich weis bei ner random zwischen 0-1 kommt wenn man ne integer macht 1 oder 0 raus aber das ist ja egal
das hab ich so aus der MySQLdb Doc raus, noch so ne frage wiso #"""# und nicht einfach #"#.
meine tabelle hat drei Spalten a: int,b: string ,c: int
mein fehler ist dann folgender:
Informatik abb 200+ gibts ne 1, mann könnte alles eingeben aber das dauert so lang
Tja leider Scheitert es schon am erstem Test
Code: Alles auswählen
import MySQLdb, md5, random
db=MySQLdb.connect(host="127.0.0.1",user="root",passwd="toor",db="pyLib")
c=db.cursor()
inputt = str(int(random.random()))+",'"+md5.new(str(random.random())).hexdigest()+"',"+str(int(random.random()))
print inputt
c.execute("""INSERT INTO one VALUES (%s);""", (inputt,))
das hab ich so aus der MySQLdb Doc raus, noch so ne frage wiso #"""# und nicht einfach #"#.
meine tabelle hat drei Spalten a: int,b: string ,c: int
mein fehler ist dann folgender:
Code: Alles auswählen
# python info-cheat.py
Code: Alles auswählen
0,'696c7ae8210f07a61b5ac4753bcbbd2e',0
Traceback (most recent call last):
File "info-cheat.py", line 6, in <module>
c.execute("""INSERT INTO one VALUES (%s);""", (inputt,))
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1136, "Column count doesn't match value count at row 1")