und wieder ich mit meinen Datenbanken . Unten seht ihr einen Python Code mit dem ich Feeds streame und diese in eine MySQL Datenbank schreiben will. Alles klappt bis auf das erstellen des Primary Keys:
So erstelle ich die Tabelle:
Code: Alles auswählen
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username - SELECT * FROM mysql.user
passwd="*****", # your password
db="python_test") # name of the data base
cur = db.cursor()
cur.execute("DROP TABLE IF EXISTS test1")
sql = """CREATE TABLE test1 (LSE_ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(LSE_ID), Unix_Timesstamp REAL, III_Timesstamp TEXT, Source TEXT, Title TEXT, Text TEXT, Link TEXT, Epic TEXT, CommentNr REAL, Author TEXT)"""
cur.execute(sql)
Code: Alles auswählen
for item in feed:
cur.execute("""INSERT INTO test1 VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)""",item)
db.commit()
Grüße und danke für die tolle Hilfe hier