query = 'INSERT INTO sfpd(`Crime Id`) VALUES("%s")'
with open(csv_file) as fh:
csv_f = csv.reader(fh)
with MySQLdb.connect(**db) as cur:
for row in csv_f:
try:
cur.execute(query, row)
if len(row) < 12:
continue
query = ''''INSERT INTO sfpd(`Crime Id`, `Original Crime Type Name`,
`Call Date`, `Offense Date`, `Call Time`,
`Call Date Time`, `Disposition`, `Address`, `City`, `State`, `Agency Id`,
`Address Type`, `Common Location`)' 'VALUES("%d", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s",
"%d", "%s", "%s")'''