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
7
votes
3 answers

using pyodbc on ubuntu to insert a image field on SQL Server

I am using Ubuntu 9.04 I have installed the following package versions: unixodbc and unixodbc-dev: 2.2.11-16build3 tdsodbc: 0.82-4 libsybdb5: 0.82-4 freetds-common and freetds-dev: 0.82-4 python2.6-dev I have configured /etc/unixodbc.ini like…
nosklo
  • 217,122
  • 57
  • 293
  • 297
7
votes
2 answers

Using an Access database (.mdb) with Python on Ubuntu

I'm trying to use pyodbc to access a .mdb on Ubuntu. I've based my progress so far on this link Query crashes MS Access I have installed pyodbc, unixodbc, and unixodbc-dev My code looks like this: import csv import pyodbc MDB = 'URY.mdb' DRV…
mythander889
  • 915
  • 5
  • 16
  • 23
7
votes
2 answers

Is it possible to read multiple result sets using a ResultProxy object in sqlalchemy?

I'm trying to call a stored procedure that returns multiple result sets using SQLAlchemy. If it matters, underneath I'm using PyODBC and FreeTDS. I call the execute() method using a raw query with "exec" calling my stored procedure on a session…
Anton I. Sipos
  • 3,493
  • 3
  • 27
  • 26
6
votes
5 answers

pyodbc connection error when trying to connect to DB on localhost

I have a local DB on my machine called 'Test' which contains a table called 'Tags'. I am able to access this DB and query from this table through SQL Server management studio 2008. However, when using pyodbc I keep running into problems. Using…
tafi
  • 227
  • 1
  • 4
  • 11
6
votes
1 answer

String data, right truncation while using fast executemany with pyodbc

I am struggling with pyodbc.ProgrammingError: ('String data, right truncation: length 636 buffer 510', 'HY000') while using executeMany() with __crsr.fast_executemany = True. When I remove this line everything works fine. I am using pyodbc…
6
votes
2 answers

ODBC Sql Server 17 driver on Mac OS X

In order to execute this python code [that works on Ubuntu 18] on a MAC, import pyodbc as odbc sql_conn_irs = odbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=xxx.xxx.xxx.xxx;DATABASE=irs;UID=xxxxx;PWD=xxxxxxxx;') I installed SQL…
Ivan
  • 7,448
  • 14
  • 69
  • 134
6
votes
2 answers

Connecting SQL Server on Docker to Python

I am trying to perform a table creation using pyodbc on a SQL Server 2017 database hosted using Docker. I'm also using a network so that I can connect to it later from another Docker image. However, I get the following error pyodbc.OperationalError:…
gpavanb
  • 288
  • 2
  • 12
6
votes
1 answer

How can I install pyodbc on Windows for use with Python 3.8?

I'm getting error on pyodbc install, i was studyng the problem and maybe its the c++ redistribute instalation problem, but even with c++ redistribute intalation updated the problem oc Follow the error when o try to install…
BR_DataMiner
  • 149
  • 1
  • 1
  • 6
6
votes
1 answer

What are the advantages and disadvantages of using pypyodbc, pymssql, and pyodbc?

I know that Pypyodbc is the newer version of Pyodbc. A question before asked about the comparison between these two but I want to add Pymssql into the mix.
HamTheBurger
  • 308
  • 1
  • 3
  • 17
6
votes
1 answer

[Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

I am unable to make a connection to the SQL server from Unix using python. I will not be able to replace the driver from ODBC Driver 17 for SQL Server to ODBC Driver 13 for SQL Server as explained in Pyodbc: Login Timeout Error due to other…
Suneel Kumar
  • 63
  • 1
  • 1
  • 4
6
votes
2 answers

Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect) when connecting to Azure SQL database from Python running in OpenShift

Only when trying to connect to my Azure DB from Python 3.7 running in a OpenShift container (FROM rhel7:latest) I see the following error: sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('IM004', "[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle…
6
votes
1 answer

How do I access AS/400 using SQLAlchemy?

Short version: Please tell me how to connect to AS/400s via SQLAlchemy. Long version My ultimate goal is to join data from SQL Server and AS/400 to be displayed in a Flask Python application. My approach has been to get the data from each database…
MarredCheese
  • 17,541
  • 8
  • 92
  • 91
6
votes
1 answer

pyodbc/sqlAchemy enable fast execute many

In response to my question How to speed up data wrangling A LOT in Python + Pandas + sqlAlchemy + MSSQL/T-SQL I was kindly directed to Speeding up pandas.DataFrame.to_sql with fast_executemany of pyODBC by @IljaEverilä. NB For test purposes I am…
Julian Moore
  • 918
  • 3
  • 11
  • 21
6
votes
2 answers

Installing pyodbc for Python 3.7 on Windows

I am a newbie to python and I need to connect to SQL Server. I run the following command in my DB_Connect.py file. I run python DB_Connect.py from CMD line and it gives error on import pyodbc. Pic of error I then I ran command pip install pyodbc…
jujulalu
  • 97
  • 1
  • 1
  • 9
6
votes
2 answers

pyodbc- connection failure to SQL Server

I have been trying to connect to Microsoft SQL Server. I have an ODBC connection set up and the test is successful. I am not using Windows Authentication to connect to SQL Server but it keep getting this error: Cannot be used with Windows…
Blue
  • 191
  • 1
  • 1
  • 12