Python to SQL Server connection -
i'm using python 3.5.1 anaconda package 2.4.0 , try make connection local sql server (2008 r2)
so doing next things:
import pypyodbc connection_string =pypyodbc.connect('driver={sql server};server=pc\mssqlserver,1433;database=localbase;uid=name;pwd=pass') connection_string=connection_string.decode(encodind='utf-8',errors='replace') after manipulations, receive error:
'utf-32-le' codec can't decode bytes in position 0-1: truncated data why's , should perform avoid , run connection properly?
you seem have misunderstood "connection string" is. text string pass to .connect method, not returned from .connect method. (what gets returned connection object.)
so, need more this:
import pypyodbc connection_string = "driver={sql server};server= ...(and on)..." conn = pypyodbc.connect(connection_string) crsr = conn.cursor() crsr.execute("select stuff tablename") # etc. 
Comments
Post a Comment