Questions tagged [pymssql]

A discontinued interface for Python that provided a standard Python DB-API interface to Microsoft SQL Server.

Pymssql was an interface for Python that provided a standard Python DB-API (as defined by PEP 249) interface to Microsoft SQL server. It was discontinued in November 2019.

Related tags:

621 questions
11
votes
1 answer

How to execute an .sql file in pymssql

I'm trying to execute an sql file in python using pymssql, this file contains a BEGIN TRANSACTION, a COMMIT TRANSACTION and an END, and some safety nets before and after. I'm trying to open the file in memory and execute the content: file =…
fragk
  • 113
  • 1
  • 8
10
votes
3 answers

Pymssql Install Error

I'm trying to install FreeTDS using binaries from here, on Windows, but I can't figure out how to install binary files; a google search turned up nothing relevant. I'm installing so that the Python module Pymssql can be imported and used. I'm…
9
votes
2 answers

Connect to SQL Server instance using pymssql

I'm attempting to connect to a SQL Server instance from a Windows box using pymssql (version 2.0.0b1-dev-20111019 with Python 2.7.1). I've tried the most basic approach from the console: import pymssql c = pymssql.connect(host =…
Allan
  • 17,141
  • 4
  • 52
  • 69
9
votes
3 answers

Pyodbc on M1 Macs

I am trying to connect to a Microsoft sql server database using pyodbc. I keep getting the error Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)") Checking…
Pawan nandakishore
  • 111
  • 1
  • 1
  • 4
9
votes
3 answers

SQLAlchemy accessing column types from query results

I am connecting to a SQL Server database using SQLAlchemy (with the pymssql driver). import sqlalchemy conn_string = f'mssql+pymssql://{uid}:{pwd}@{instance}/?database={db};charset=utf8' sql = 'SELECT * FROM FAKETABLE;' engine =…
Sumedh
  • 4,835
  • 2
  • 17
  • 32
9
votes
4 answers

get column names from query result using pymssql

Is there any way to get the column names from the pymssql results? If i specify as_dict=True I get back a dictionary, which does contain all the column headers, but since it is a dictionary they are not ordered.
MK.
  • 33,605
  • 18
  • 74
  • 111
9
votes
1 answer

pymssql: How to use windows authentication when running on a non-windows box

Is there a way for python to connect to MS SQL Server using Windows Authentication, even when not running the python app on a windows box? I'm trying to do this with pymssql, but the examples mostly seem to assume that you're running on windows. If…
Dan
  • 3,665
  • 1
  • 31
  • 39
8
votes
1 answer

How can I create a database using pymssql

Im trying to create a database using pymssql and im getting this error. cur.execute("CREATE DATABASE %s;" % self.getsql('dbname'), conn) gives *** OperationalError: (226, 'CREATE DATABASE statement not allowed within multi- statement…
jagguli
  • 631
  • 1
  • 7
  • 21
8
votes
0 answers

Finally got pymssql to install, but it won't import

I'm use 64-bit windows, Python 2.7 in PyCharm. The wheel would not install, but I finally got install pymssql by extracting the zip (and instructions I found here: How to install pymssql on windows with python 2.7?) and moving the files into the…
stahna
  • 193
  • 1
  • 1
  • 9
8
votes
2 answers

Using cursor.execute arguments in pymssql with IN sql statement

I have troubles using a simple sql statement with the operator IN through pymssql. Here is a sample : import pymssql conn = pymssql.connect(server='myserver', database='mydb') cursor = conn.cursor() req = "SELECT * FROM t1 where id in…
Alex
  • 816
  • 5
  • 14
8
votes
4 answers

Using pymssql to insert datetime object into SQL Server

How do I insert a datatime object using pymssql? I know that the SQL Server table is expecting a datetime object, let's say in position 3. I've tried all three of these: cursor.execute("INSERT INTO MyTable VALUES(1, 'Having Trouble',…
scharfmn
  • 3,561
  • 7
  • 38
  • 53
7
votes
4 answers

Insert Data to SQL Server Table using pymssql

I am trying to write the data frame into the SQL Server Table. My code: conn = pymssql.connect(host="Dev02", database="DEVDb") cur = conn.cursor() query = "INSERT INTO dbo.SCORE_TABLE VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,…
Krishnang K Dalal
  • 2,322
  • 9
  • 34
  • 55
7
votes
5 answers

Adaptive server connection failed (DB-Lib error message 20002, severity 9)

I'm sure this issue has been raised an uncountable number of times before but perhaps, someone could still help me. I am using pymssql v2.1.3 with Python 2.7.12 and the code that I used several times until yesterday to write data to my Azure SQL DB…
Syed
  • 340
  • 1
  • 3
  • 13
7
votes
1 answer

pymssql executes stored procedure but returns no results

I am trying to execute a stored procedure on a SQL server and save the results using python -- I decided to use pymssql because it seemed like the simplest solution. print pymssql.__version__ server = 'MY\SERVER' user = 'user' password =…
learningcs
  • 1,856
  • 16
  • 25
7
votes
3 answers

ImportError: No module named _mssql

I'm running Python 2.7.2 on OS 10.8.5 Trying to use pymssql, but I get the following error: File "time_reporting.py", line 32, in import pymssql File "/Users/xx/.virtualenvs/oracle/lib/python2.7/site-packages/pymssql.py", line 30,…
thumbtackthief
  • 6,093
  • 10
  • 41
  • 87
1
2
3
41 42