Upon inserting the data into the MS SQL Server DB, my values are getting truncated and single extra space is added in between. For eg:-
HomeShop18
is saved as H o m e s
. It is truncated as well and space is also included.
But when I do select * from table where col= 'Homes'
it shows the data. What is the problem?
How can I insert the data into the SQL Server DB?
Here's what I'm currently doing? PS : I have read threads on SO pointing out to increase the size and TDS version. I've tried it all but still the inserting entry is truncated.
def post_data(data):
os.environ['TDSVER'] = '8.0'
data = (
data['AWB_Number'], data['Weight'], data['Length'], data['Height'],
data['Width'], data['Customer_Name'], datetime.datetime.strptime(data['Scan_Time'][:19] , '%Y-%m-%d %H:%M:%S'),data['Series_Flag']
)
print data # ('40642847766', '0.011', '1.1', '1.1', '1.1', 'flipkart', datetime.datetime(2014, 8, 14, 11, 14, 53), 'True')
con_string = 'DSN=%s;UID=%s;PWD=%s;DATABASE=%s;' % (dsn, user, password, database)
cnxn = pyodbc.connect(con_string)
cursor = cnxn.cursor()
cursor.execute("insert into data_AutoScale_DELHUB(AWB_Number,Weight,Length,Width,Height,Customer_Name,Scan_Time,Series_Flag) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" , data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7])
cursor.commit()
cnxn.close()