Datum in MySQL DB schreiben
Verfasst: Freitag 29. April 2011, 10:34
Hallo,
ich bin noch recht neue in Sachen Python. Mein aktuelles großes Problem:
Ich lese aus einer CSV Datei zwei Datumswerte (beide im Format DD.MM.YYY) und will sie in ein Date- und ein Timestamp-Feld einer MySQL Db schreiben.
Mein Versuch:
Dann habe ich jedoch nur 0000-00-00 in der Spalte Valid_From und 0000-00-00 00:00:00 in Doc_Date.
Gruß
ich bin noch recht neue in Sachen Python. Mein aktuelles großes Problem:
Ich lese aus einer CSV Datei zwei Datumswerte (beide im Format DD.MM.YYY) und will sie in ein Date- und ein Timestamp-Feld einer MySQL Db schreiben.
Mein Versuch:
Code: Alles auswählen
.....
File = csv.reader(open('I:\test.csv', 'rb'))
for row in File:
Doc_Date = time.strptime(row[6],"%d.%m.%Y")
Valid_From = time.strptime(row[10],"%d.%m.%Y")
cursor.execute ( """INSET INTO Test (Datum) VALUES (%s, %s)""", ( Doc_Date, Valid_From ) )
.....Gruß