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

How can we write pandas dataframe to a Netezza Database directly using pyodbc?

I have Netezza database at remote server and i am trying to write to the database using Pyodbc. The connection work's while reading from the database..However while trying to write i am not able to write to the Netezza database. It shows the…
Shoaib
  • 11
  • 1
1
vote
1 answer

How do I create a query object into the Microsoft Access database?

I can successfully connect to the Microsoft Access database; however, I am having trouble understanding how to create an Access Database object for a query. Once created, I am trying to verify it as an object in the database. I tried a few of the…
1
vote
2 answers

DateTime Overflow with Valid Date Access Insert

To anyone that can help, thank you. I am getting a very strange error when running a INSERT statement using pyodbc. The error code is: cursor.execute(QueryInsert,params) pyodbc.DataError: ('22008', '[22008] [Microsoft][ODBC Microsoft Access…
user78913
  • 73
  • 7
1
vote
2 answers

Passing a Python List through a SQL Statement on a Loop

I am trying to figure out how to pass a list as a parameters through a where statement in SQL, I can not program what I am looking for, but below is what I am looking for. This is what I would do for one parameter.... x = 1 sql = """Select…
Anthony Richard
  • 127
  • 2
  • 12
1
vote
0 answers

error:pyodbc.Error: ('HY010', '[HY010] [Microsoft][ODBC Driver 17 for SQL Server]Function sequence error (0) (SQLParamData)')

when I try to insert the excel file data into sql server **pyodbc.Error: ('HY010', '[HY010] [Microsoft][ODBC Driver 17 for SQL Server]Function sequence error (0) (SQLParamData)') ** import pandas as pd import pyodbc import numpy as…
1
vote
2 answers

With statement in PYODBC sql statement

I am not able to execute a SQL statement with pyodbc if I use the With clause in the SQL statement. This works: import pyodbc cnxn = pyodbc.connect('DSN=database;PWD=password' ) cursor = cnxn.cursor() sql = """ SELECT top 10 * …
Oxford_orange
  • 157
  • 1
  • 10
1
vote
2 answers

Pyodbc not returning error from SQL Server

Ok, hopefully this is something really silly that I'm overlooking... I'm using Python 3.7.2 and Pyodbc 4.0.24 on SQL Server 17 (14.0.2002.14) On my SQL Server I create a table as such: create table test( test1 varchar(5) ) But when I try to…
gbeaven
  • 1,522
  • 2
  • 20
  • 40
1
vote
1 answer

Prefetch_related failing against SQL Server

Using Django 2.X, and Pyodbc driver (installed from anaconda conda-forge django-pyodbc-azure) against MS Sql Server (not sure which version), I regularly have bugs using prefetch_related. An example looks simply like: for obj in…
scnerd
  • 5,836
  • 2
  • 21
  • 36
1
vote
1 answer

pyodbc bulk data import challenge using cursor.executemany( query, df.itertuples(index=False) )

I am reasonably new to python but have given this a serious bash to solve this elegantly. The challenge: I am wanting to import market data from a pandas df into a sql table. There are some 7000 different stocks and each has some 4000-10000 End of…
Luthor
  • 93
  • 1
  • 11
1
vote
2 answers

Need help in fixing sql connection issue using service account though pyodbc

When I try to run the below code I am getting following error. Tried referring other posts but it does not seem to help. The server principal "{Myuser}" is not able to access the database "{database}" under the current security context. (916)…
Vaibhav
  • 102
  • 1
  • 9
1
vote
1 answer

Python, Django and pyodbc: invalid characters

I am connecting to a MS SQL server database using pyodbc. The error im getting is the following invalid byte sequence for encoding "UTF8": 0x93 HINT: This error can also happen if the byte sequence does not match the encoding expected by the…
neolaser
  • 6,722
  • 18
  • 57
  • 90
1
vote
1 answer

Creating stored procedure in MS SQL through pyodbc

I am trying to create a store procedure in master in mssql through python code. The following is my code: import pyodbc conn = pyodbc.connect("driver={SQL Server};server=localhost; database=master; trusted_connection=true", …
learner
  • 332
  • 2
  • 6
  • 22
1
vote
1 answer

Python to SQL Connection. Trying to push pandas dataframe to SQL Server

Anyone know how to solve this error? Trying to connect to Azure SQL Server. Thanks a ton! InterfaceError: (pyodbc.InterfaceError) ('IM002', u'[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified…
1
vote
0 answers

Python Connection to database without pyodbc

I'm quite new to Python (using Python 3.6.5) and I need to create a connection to a database, and I do it in Access with the ODBC Driver (I guess?), but for some reasons I just can't install pyodbc here, so I need to do this connection without it.…
1
vote
2 answers

Process finished with exit code -1073741819 (0xC0000005) in PyCharm, RESTART: Shell in IDLE, and closes console

I'm trying to connect c-TreeSQL using Python. I know I have the correct driver because I can connect using George Poulose's Query Tool I have tried these variations and each one has crashed; import pyodbc ## Instructions from…
1 2 3
99
100