Questions tagged [pyodbc]

pyodbc is a module that allows you to use Python to make a database connection using ODBC

pyodbc is a Python 2.x and 3.x module that allows you to use ODBC to connect to almost any database from Windows, Linux, OS/X, and more.

It implements the Python Database API Specification v2.0, but additional features have been added to further simplify database programming.

pyodbc is licensed using an MIT license, so it is free for commercial and personal use. You can even use the source code in your own projects.

Installing can be done by running:

pip install pyodbc

Most Linux distributions are starting to provide pre-compiled packages, but those versions are often quite outdated.

Full source code is also available from the GitHub repository.

3768 questions
10
votes
4 answers

How to use Django with Sql Server

I normally use Postgres for my database needs with Django but I recently started at a company which use MSSQL on a Windows environment. Long story short I had to rewrite the database properties in settings.py. Unfortunately, I have NO idea how to…
Will.Beasley
  • 141
  • 2
  • 2
  • 7
10
votes
3 answers

How to get the last created ID in SQL

I created a table called participant composed by participant_ID (which is the primary key and is identity[has an auto-value]) and session_ID (which is a foreign key). When I create a new participant, I would like to store its participant_ID. I have…
vcvd
  • 422
  • 2
  • 7
  • 13
10
votes
1 answer

Having Troubles with UnixODBC, FreeTDS, and PyODBC

I am having great difficulty getting all three of these to work together in harmony. I guess I'll list all the various configurations, along with the test code to see if a pair of fresh eyes can realize my stupidity. I'm running 12.04 Ubuntu Server…
Anthony Tantillo
  • 300
  • 1
  • 3
  • 12
10
votes
3 answers

Connecting to SQL Server with pypyodbc

I need to send unicode to SQL Server with Python 2.7. I failed with pymssql. I'm now trying to get pypyodbc working (as opposed to pyodbc), as it gives working unicode examples. The problem is that the connection string in the example doesn't…
scharfmn
  • 3,561
  • 7
  • 38
  • 53
9
votes
2 answers

connecting sqlalchemy to MSAccess

How can I connect to MS Access with SQLAlchemy? In their website, it says connection string is access+pyodbc. Does that mean that I need to have pyodbc for the connection? Since I am a newbie, please be gentle.
Jack_of_All_Trades
  • 10,942
  • 18
  • 58
  • 88
9
votes
1 answer

How to ensure a SQL like NOLOCK when using Django Model Queries

I have a Django Model "Users" tied to an existing MS SQL Server database table. I am reading the table thus: Users.objects.filter(userid='xyz').filter(status='active') I want to know what locking constructs would this translate to, as in, would…
Sid
  • 7,511
  • 2
  • 28
  • 41
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
1 answer

Connecting to MS Access 2007 (.accdb) database using pyodbc

I am on Win7 x64, using Python 2.7.1 x64. I am porting an application I created in VC++ to Python for educational purpouses. The original application has no problem connecting to the MS Access 2007 format DB file by using the following connection…
havelock
  • 171
  • 1
  • 1
  • 10
9
votes
5 answers

Connecting to MS SQL Server using python on linux with 'Windows Credentials'

Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials? I can connect perfectly fine from my windows machine using Windows Credentials, but attempting to do the same from a linux python with…
Samer Atiani
  • 695
  • 1
  • 6
  • 8
9
votes
2 answers

Convert list of pyodbc.rows to pandas Dataframe takes very long time

Is there a faster way to convert pyodbc.rows object to pandas Dataframe? It take about 30-40 minutes to convert a list of 10 million+ pyodbc.rows objects to pandas dataframe. import pyodbc import pandas server = database =
Anjana Shivangi
  • 397
  • 2
  • 5
  • 19
9
votes
3 answers

Connecting to SQL Server named instance from Linux using pyodbc

I'm currently trying to connect to a SQL Server (that I don't have visibility into, but have credentials for) using PyODBC. The code that I have works on my Windows desktop, but does not work when moved onto my RedHat Linux machine. I need it on…
sdberts
  • 85
  • 1
  • 1
  • 3
9
votes
3 answers

Automatically Detect ODBC Driver using Pyodbc in Python 3

Hi I'm currently using pyodbc in Python 3 and I'm trying to figure out a way to automatically detect ODBC Driver by not having to change manually when used by different computers. The reason is because my computer has ODBC Driver 13 and another…
DanLee
  • 339
  • 1
  • 4
  • 11
9
votes
2 answers

PYODBC truncates the response of a SQL Server FOR JSON query

I'm having issues trying to get a SQL Server JSON result set to play nicely with PYODBC. My Python/Flask skills aren't the best, so I'm not entirely sure if this is something stupid I'm doing, or that the driver doesn't work with JSON. The failing…
Mark Sinkinson
  • 970
  • 6
  • 18
9
votes
3 answers

Installation failed trying to install MySQL ODBC connector on macOS High Sierra

I'm trying to install this mysql odbc connector on my macOS High Sierra machine, but I get this error: I tried installing it using installer in the hopes of getting information about what went wrong: ➜ ~ sudo installer -pkg…
L42
  • 3,052
  • 4
  • 28
  • 49
9
votes
1 answer

Python pyodbc cursor vs database cursor

I use python every day with a heavy emphasis on database work. Using pyodbc my standard start is something like connection_hostname = pyodbc.connect('connection_string') cursor_hostname = connection_hostname.cursor() command_hostname = 'select *…
zentechinc
  • 369
  • 1
  • 5
  • 15