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

Error when move data from database to another

Error on ETL code on python I managed to learn some lines of code on python to perform ETL processes in MS SQL environment. the initial script was for PostgreSQL environment. I want to use mine for MS SQL. I tried editing the code however I got an…
AKP
  • 89
  • 1
  • 1
  • 14
1
vote
1 answer

fetchall() throws "Previous SQL was not a query." for DELETE query

I have a python script which connects to sql server instance. I running a cte query to remove duplicates. The query run sucessfully but when i used the fetchall() function it results in an Error: the previous query is not a sql query and after…
pratha1995
  • 103
  • 1
  • 14
1
vote
1 answer

"No results. Previous SQL was not a query" when trying to query DeltaDNA with Python

I'm currently trying to query a deltadna database. Their Direct SQL Access guide states that any PostgreSQL ODBC compliant tools should be able to connect without issue. Using the guide, I set up an ODBC data source in windows I have tried adding…
Oliver
  • 11
  • 2
1
vote
1 answer

Specifying column criteria in SQL query through pyodbc causes errors

I am running a query to MS SQL Server through pyodbc: conn = pyodbc.connect('DRIVER={ODBC Driver 11 for SQL Server};SERVER=some_server, some_port;DATABASE=MAP;UID='xxx';PWD='xxx') cursor = conn.cursor() query = """SELECT v_MAMain.MAID,…
barciewicz
  • 3,511
  • 6
  • 32
  • 72
1
vote
1 answer

pyodbc cannot connect to on-premises MSSQL server

I want to connect to MSSQL server2012 from Python using pyodbc on a Debian8 host. The current code already works for Azure SQL server but not for local SQL server. The connection string looks like this: import pyodbc server = 'IP' database =…
sherry
  • 11
  • 2
1
vote
2 answers

Having problem connecting python and SQL through pyodbc (no default driver specified)

I´m having problem connecting SQL and python through pyodbc. I´ve tried most of the drivers names and inclusions in the system, but I keep having the same issue. CODE: import pyodbc conn = pyodbc.connect( "Driver='{SQL Server Native Client…
1
vote
1 answer

How to improve the write speed to sql database using python

I'm trying to find a better way to push data to sql db using python. I have tried dataframe.to_sql() method and cursor.fast_executemany() but they don't seem to increase the speed with that data(the data is in csv files) i'm working with right now.…
dguy73
  • 71
  • 7
1
vote
1 answer

How can I insert a list returned from pyodbc mssql query into mysql through stored procedure using pymysql

I am pulling data from a MSSQL db using pyodbc which returns my data set in a list. This data then needs to be transferred into a MySQL db. I have written the following stored procedure in MySQL. CREATE DEFINER=`root`@`localhost` PROCEDURE…
gacto
  • 301
  • 4
  • 10
1
vote
2 answers

PyODBC on Snow Leopard - Install Error

Has anyone succesffuly installed PyODBC on snow leopard? I'm getting the error below. (I also submitted a bug here too) Any ideas how to fix this and get it installed? Here is the output I'm getting: $ python setup.py install running…
Greg
  • 45,306
  • 89
  • 231
  • 297
1
vote
2 answers

Can't connect to SQL Server DB from Pyodbc

I am having a difficult time trying to connect to a SQL Server DB on Linux, using pyodbc. I have a ODCINI file entry created. I started with this: import pyodbc conn = pyodbc.connect('DSN=DSN;Database=DB;UID=UID;PWD=PWD') cursor =…
JD2775
  • 3,658
  • 7
  • 30
  • 52
1
vote
1 answer

How to Save a Data Frame as a table in SQL

I have a SQL Server on which I have databases that I want to use pandas to alter that data. I know how to get the data using pyodbc into a DataFrame, but then I have no clue how to get that DataFrame back into my SQL Server. I have tried to create…
akerr
  • 11
  • 1
  • 5
1
vote
1 answer

Kinit Inside a python console not working

I am trying to use kinit method inside a Python console and its not working. This is what I am trying in the macOS terminal. I've already generated the Keytab file kinit ABC@XXXX.ORG -k -t xyz.keytab and then invoke the python command line and then…
Bharat Guda
  • 117
  • 3
  • 14
1
vote
1 answer

Connection to Linked Access Database Using pyodbc

I am trying to get data from a Microsoft Access Database. The issue is the number of constraints I'm under: I have to use 64 bit Python The access database is made up of linked tables to a different database The other database requires a 32 bit…
A. Hudson
  • 51
  • 1
  • 10
1
vote
1 answer

Add multiple sheets in existing excel using pandas in Python

My code is reading SQL queries from text file and executing them one by one in python.I am trying save result of queries in the same excel but in different tabs/worksheets import pyodbc as hive import pandas as pd filename…
1
vote
0 answers

Python code when compiled on ubuntu16.04 is not working when interacting with db using pyodbc module and giving sql exceptions

I have a big python tool that works perfectly when executed the binary that was compiled on a ubuntu14.04 machine, but the same tool is not working when compiled on 16.04 and it is giving me sql exceptions like below when my code tries to…
v sai teja
  • 21
  • 1