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
1
vote
1 answer

Change where pyodbc expects libodbc.2.dylib to live (changing default odbc file locations)

When importing pyodbc ❯ python >>> import pyodbc Traceback (most recent call last): File "", line 1, in ImportError: dlopen(/Users/pcosta/Documents/test/myenv/lib/python3.7/site-packages/pyodbc.cpython-37m-darwin.so, 2): Library…
Paulo Costa
  • 965
  • 2
  • 10
  • 15
1
vote
2 answers

pyodbc ImportError: DLL load failed: The specified module could > not be found

When trying to import pyodbc i get the below error. How do I resolve this? All other things I have found on here has not worked. I have also tried everything on this site:…
Sven
  • 301
  • 2
  • 18
1
vote
1 answer

Connect to SQL server using pyodbc and sqlalchemy, cannot use "use database_name;"

My code is as follows: import urllib import sqlalchemy from sqlalchemy.orm import sessionmaker, scoped_session def list_dbs(): sql = """ use master; SELECT name FROM sys.databases; """ try: …
mutoulion
  • 13
  • 3
1
vote
2 answers

SQL Server DateTimeOffset changes the offset of a tz aware datetime to the system offset when using pyodbc

I have a problem uploading a timezone aware datetime from python to the SQL server datatype datetimeoffset. No matter which timezone upload to SQL Server, it always displays the offset in system time offset. It is not converting the actual datetime…
milanDD
  • 123
  • 1
  • 11
1
vote
1 answer

Login timeout expired error when connecting to a local sql server using pyodbc

when trying to connecnt to my local sql server i keep on getting the following error: pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') this is my code: import…
1
vote
1 answer

seems like pyodb is installed but gives error saying module is not found python 3.7.5. Jupyter lab

I used pip to install pyodbc. C:\Windows\system32>pip install pyodbc Requirement already satisfied: pyodbc in c:\users\username\appdata\local\programs\python\python37\lib\site-packages (4.0.28) But if I simply import pyodbc it gives me an…
Serdia
  • 4,242
  • 22
  • 86
  • 159
1
vote
0 answers

Access Hive via pyodbc gets ParseException with extra EOF

Python: 3.6.8 pyodbc: 4.0.27 OS: ubuntu 18.04 DB: Hive 0.13 driver: Hortonworks ODBC driver for Hive downloaded at http://public-repo-1.hortonworks.com/HDP/hive-odbc/2.1.2.1002/debian/hive-odbc-native_2.1.2.1002-2_amd64.deb I'm able to connect…
zpz
  • 354
  • 1
  • 3
  • 16
1
vote
1 answer

Pandas to_sql Parameters & Performance

I'm currently trying to tune the performance of a few of my scripts a little bit and it seems that the bottleneck is always the actual insert into the DB (=MSSQL) with the pandas to_sql function. One factor which plays into this is mssql's parameter…
zeitghaist
  • 89
  • 9
1
vote
1 answer

login to obiee and execute SQL using python

I've tried various ways of extracting reports from Oracle Business Intelligence (not hosted locally, version 11g), and the best I've come up with so far is the pyobiee library here, which is pretty good: https://github.com/kazei92/pyobiee. I've…
Plato77
  • 422
  • 3
  • 15
1
vote
1 answer

Is there a way with pandas to use read_sql() with an sql-statement, that takes multiple variables?

this is a part of my code. I already have a database with values in it, and need to create a new dataframe based on the values out of this dataframe (at the moment these values are only 12 & 13, stored in the header_row_ids variable). When I run the…
Civan Öner
  • 65
  • 1
  • 8
1
vote
1 answer

Connection issues using pandas.Dataframe.to_sql and sqlalchemy?

I've been trying to insert a Pandas dataframe into an SQL Server I have running on Docker. I'm using python 3.6.9 on Ubuntu 18.04. # import the module from sqlalchemy import create_engine import pyodbc # create sqlalchemy engine engine =…
1
vote
1 answer

Get server name (SQL Server Host) through SQL Alchemy session or engine

Where is the server name found in the SQL Alchemy session or engine? I prefer not parsing the query property. e = connManager.get_engine() e.engine.url mssql+pyodbc:///?odbc_connect=DRIVER={SQL Server Native Client…
dirtyw0lf
  • 1,899
  • 5
  • 35
  • 63
1
vote
1 answer

Python execute sql file error pyodbc 'HY090', '[HY090] [Microsoft][ODBC Driver Manager] Invalid string or buffer length (0) (SQLExecDirectW)'

import sql_connect def main(): # check if db exists on target, if not create qry_create_db = "if not exists(select * from sys.databases where name = '{}') create database {};".format('mydb','mydb') with…
sam
  • 95
  • 1
  • 2
  • 10
1
vote
0 answers

Python pyodbc Duplicate key was ignored

I am using pyodbc and requests module to pull data using web api and push it to my database- SQL server. I making a requests and make a loop over the response inserting it into my database. in my table column costc is the unique value Everything…
Yuval
  • 45
  • 4
1
vote
1 answer

Could not connect newly created SQL Server database using pyodbc

I have configured a new SQL Server 2017.XXX instance in my Windows 10. Then, created a new database called CUSTOMER_DEVICES. I tried to connect to database using pyodbc. I could not and got below error: Error - pyodbc.OperationalError: ('08001',…
Shabnam K
  • 1,572
  • 1
  • 9
  • 10