का उपयोग कर एक एमएस एसक्यूएल तालिका में डेटाटाइम डालना मैं pyodbc का उपयोग कर एक एमएस एसक्यूएल सर्वर तालिका में डेटाटाइम मान डालने का प्रयास कर रहा हूं। अगर मैं इसे मैन्युअल रूप से करते हैं, कुछ की तरह:pyodbc
cursor.execute("""insert into currentvalue(value1,currentdatetime)
values(55,'2014-06-27 16:42:48.533')""")
मुझे कोई समस्या नहीं सब पर है, लेकिन जब मैं करने की कोशिश:
SQL server Incorrect syntax near '07' which i think is the number after the date and starting the time.
: मैं यह त्रुटि आई
currenttime = str(datetime.datetime.now())
cursor.execute("""insert into currentvalue(value1,currentdatetime)
values(55,"""+ currenttime+")")
इसके अलावा मैंने यह कोशिश की:
currenttime = "'"+str(datetime.datetime.now())+"'"
और अब इस त्रुटि आता है:
Conversion failed when converting date and/or time from character string.
उपयोग [मापदंडों] (https://code.google.com/p/pyodbc/wiki/GettingStarted#Parameters)। – Bryan