Monday, 15 August 2011

Inserting date/timestamp values into SQL Server table using Python -



Inserting date/timestamp values into SQL Server table using Python -

i have 3 variables stored number, string , string, shown below.

load_id = 100 t_date = '2014-06-18' p_date = '19-jun-14 10.51.45.378196'

i insert them sql server table using python 2.7. sql server table construction follows

load_id = float t_date = date p_date = timestamp

in oracle, tend utilize to_date or to_timestamp convert string date or timestamp field.

i know how can similar conversion while inserting sql server table.

thanks in advance.

convert :

import datetime import calendar thedate=datetime.datetime.strptime(p_date,'%d-%b-%y %h.%m.%s.%f') thetimestamp=calendar.timegm(thedate.utctimetuple())

python-2.7

No comments:

Post a Comment