1
我想將這個查詢發佈到我的數據庫中。問題是我從包含佔位符的csv查詢:我似乎無法得到:Time_Date_Uploaded
varchar(255)DEFAULT NULL填充當前時間。這裏是我的代碼如下:找不到python查詢。
cursor = mydb.cursor() # declare object
now = time.strftime('%Y-%m-%d %H:%M:%S') #want to send the current time to the database.
cr.next() # need to skip first line of csv
for row in cr:
cursor.execute('INSERT INTO loans2(LoanId, NoteId, OrderId, OutstandingPrincipal, AccruedInterest, Status, AskPrice, Markup_Discount, YTM, DaysSinceLastPayment, CreditScoreTrend, FICO_End_Range, Date_Time_Listed, NeverLate, Loan_Class, Loan_Maturity, Original_Note_Amount, Interest_Rate, Remaining_Payments, Principal_plus_Interest, Time_Date_Uploaded) VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")' % tuple(row))
# #close the connection to the database.
mydb.commit()
cursor.close()
print "Done"
謝謝你!完美的作品。 Unfort不能upvote說我需要15點聲望或什麼的。 – nematillo 2015-02-07 21:15:06