pymssql

Convert or strip out "illegal" Unicode characters

I've got a database in MSSQL that I'm porting to SQLite/Django. I'm using pymssql to connect to the database and save a text field to the local SQLite database. However for some characters, it explodes. I get complaints like this: UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 1916: ordinal not in range(128) Is ...

Copy whole SQL Server database into JSON from Python

I facing an atypical conversion problem. About a decade ago I coded up a large site in ASP. Over the years this turned into ASP.NET but kept the same database. I've just re-done the site in Django and I've copied all the core data but before I cancel my account with the host, I need to make sure I've got a long-term backup of the data s...

optimize pymssql code

i am inserting records to sql server from python using pymssql. The database takes 2 milliseconds to execute a query, yet it insert 6 rows per second. The only problem is at code side. how to optimize following code or what is the fastest method to insert records. def save(self): conn = pymssql.connect(host=dbHost, user=dbUser, ...

Can't connect to SQL Server 2005 Express from an ASP.NET C# page

Hey guys, I have an MS SQL Server 2005 Express running on a VPS. I'm using pymssql in Python to connect to my server with the following code: conn = pymssql.connect(host='host:port', user='me', password='pwd', database='db') and it works perfectly. When I try to connect to the server from an ASP.NET C# page with the following code: ...

Python - Linux - Connecting to MS SQL with Windows Credentials - FreeTDS+UnixODBC + pyodbc or pymssql

There doesn't seem to be any great instructions for setting this up. Does anyone have any good instructions? I am a linux noob so be gentle. I did see another post that is similar, but no real answer. I have a couple of problems. FreeTDS doesn't "seem" to be working. I am trying to connect and I get the following message using t...

MySQL + Python (IronPython) timeout problem

I'm querying MS SQL using python using the source code from http://www.ironpython.info/index.php/Accessing_SQL_Server: import clr clr.AddReference('System.Data') from System.Data import * TheConnection = SqlClient.SqlConnection ("server=yourserver;database=News;uid=sa;password=password;timeout=0") TheConnection.Open() MyAction = SqlCl...

Next question about russian encoding, mssql and python.

Next question about russian encoding, mssql and python. I have this simple code: import pymssql import codecs conn=pymssql.connect(host='localhost:1433', user='sa', password='password', database='TvPgms') cur = conn.cursor() cur.execute('SELECT TOP 5 CAST( Name AS nvarchar(400) ), CONVERT(nvarchar(400), idProgram) FROM dbo.Programs') ...

How do I use SQL parameters with python?

I am using python 2.7 and pymssql 1.9.908. In .net to query the database I would do something like this: using (SqlCommand com = new SqlCommand("select * from Customer where CustomerId = @CustomerId", connection)) { com.Parameters.AddWithValue("@CustomerID", CustomerID); //Do something with the command } I am trying to figure...

Using Microsoft SQL through python on a webserver

I'm trying to run some queries to a database from a pylons (paster-based) webserver and every time I try to import the pymssql Library I'm using (its this one by the way) I keep getting this error: tds_init_winsock: WSAEnumProtocols failed with 10055(WSAENOBUFS: No buffer space available.) on the import. I also tried using sqlalchemy ...

Python + pymssql to replace 'Microsoft SQL Server Management Studio Express' ?

Hi All, Currently I'm talking to a MS SQLServer using 'Microsoft SQL Server Management Studio Express'. I would like to execute the scripts written using 'Microsoft SQL Server Management Studio Express' from the python environment. For this, I have connected to the MS SQLServer using pymssql but I'm finding translating the existing SQ...