Questions tagged [pyodbc]

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

1
vote
1answer
21 views

Able to access data through pyodbc and SELECT statements, but no new tables show up in SQL

I have the following code which is working with no errors and returning the expected output when I print the results of the pyodbc cursor I created. cnxn = pyodbc.connect(MY_URL) cursor = cnxn.cursor(...
0
votes
0answers
19 views

How to connect to Teradata Server using sqlalchemy and DSN less connection

I can't figure out the right ODBC string I need to pass to the create engine statement. This works import pyodbc import pandas as pd cnxn=pyodbc.connect('DRIVER=/opt/teradata/client/ODBC_64/lib/...
0
votes
0answers
24 views

Python and pyodbc with SQL Server. How do I get decimal data from SQL Server when the precision increases?

I have a SQL Server database table with two columns f1 & f2. These are defined in SQL Server as f1 DECIMAL (10, 4) f2 DECIMAL (13, 4) When I select using python and pyodbc and loading the data ...
0
votes
0answers
25 views

Python For loop only running for the last value of the input sql query

Issue with the below Python script only using the last value in the query that I am using as the input to the first For loop. It should run for all employee id's returned and pull the photo from the ...
0
votes
1answer
50 views

Need help iterating through Python dict keys/values and INSERTing into SQL DB

I made a call to request data from Weight Gurus, which returns in the format of a python dictionary with keys and values of course. I need to take the data retrieved from this call and INSERT each ...
0
votes
1answer
35 views

Errors on connection to MSSQL using turbodbc

I cannot connect using values read from a config file. This is on Windows, connecting to SQL Server 2008r2 on the same machine, using Python 3.6. This works: conn = p.connect(driver = '{SQL Server ...
0
votes
0answers
31 views

inserting dataframe into Oracle Datebase using pyodbc: Error: ('HY000', 'The driver did not supply an error!')

I am trying to insert a dataframe into an Oracle Database using pyodbc. My code looks as follows: pyodbc.pooling = False conn_str = ( r'DRIVER={Oracle in OraClient12Home1};' r'UID=***;' ...
0
votes
0answers
29 views

Query execution failed: \r\nTable already exists. (Tablename: django_migrations)

I have a project where i need to use django with Nexus DB. I have customized django-pyodbc package to nexusDB compactable as third party Database engine. But While making the initial migration found ...
0
votes
0answers
27 views

Remote connection to MSSQL 2012 is working but not from Local server

I have created a python 3.7.2 script to connect with MSSQL 2012 R2 Datacenter, I am able to connect with db from Remote that's from my Laptop and fetch the data in the table and saving it as xxxxx....
0
votes
0answers
19 views

Multiple SQL update queries spanned in few functions (pyodbc)

I have a sql db-connection that among all other things, has a function to update (lets say 4) tables that are dependent on each other. I originally had the queries all together in one function ...
0
votes
1answer
47 views

Pyodbc driver/DSN not found AWS lambda - works on EC2

I am trying to connect to SQL Server using PYODBC inside AWS Lambda. I set up an EC2 instance and installed all dependencies and packages needed. I am able to query SQL within EC2 but not within ...
0
votes
0answers
20 views

Is there any way to put timeout in pandas read_sql function?

I connect to a DB2 server through ODBC connection in my python code. The DB2 server gets reboot for maintainence or disconnects me while running specific server side tasks, happens 1 or 2 times in a ...
1
vote
1answer
29 views

“Invalid object name” error on INSERT to SQL Server from pyodbc

I am trying to insert some data into a SQL Server database using the pyodbc module. I have the connection string working. The following code lists the two columns in the table. for row in cursor....
2
votes
2answers
44 views

pyodbc: ORACLE SQL Statement with WHERE Clause that incorporates date range

I am using pyodbc to extract data from a database table. Now, I would like to limit the query to only contain the records that were added within the last 24 hrs. The information about the time a ...
2
votes
0answers
40 views

How to transform a generator into a dataframe

I'm importing some data from an SQL Server and transforming them into dataframes with pandas as it follows: cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;UID=user;PWD=password') DF = pd....
0
votes
1answer
41 views

Dynamically build dictionary from columns specified at runtime

I have been told I need to use a mapping table instead of a hardcoded dictionary I made. There has to be a better method than the code below to get a 3 column table into a dictionary? Mapping table ...
0
votes
1answer
37 views

Trying to connect to Sybase and Azure SQL server using python with TLS enabled connections

I am tyring to connect from AWS to Sybase database and Azure SQL server using python (pymssql) and have the TLS enabled on the connections. This does not seem work even after trying (How to configure ...
0
votes
0answers
23 views

pyodbc InterfaceError: sqlalchemy.create_engine(mssql+pyodbc://…) [duplicate]

The create_engine() statement doesn't seem to work when using mssql+pyodbc, it throws an InterfaceError. The same happens when I try to use turbodbc. However, it works fine when using mssql+pymssql. ...
1
vote
0answers
32 views

Getting pyodbc to connect in AWS Lambda Layer

I have built deployment package to connect to a AWS RDS instance via pyodbc, after zipping up and uploading to AWS lambda this connection works. When trying to connect via an AWS layer, following ...
0
votes
1answer
15 views

ORA-00936: missing expression when using pyodbc to extract specific data from a SQL server

Unable to understand why my sql query is throwing an exception of [Oracle][ODBC][Ora]ORA-00936: missing expression. The case is that the code seems to be working fine when I'm using select* from ...
0
votes
0answers
33 views

Connecting to a SQL Server data base in Jupyter using unixODBC

When trying to connect to the server/database I'm getting this error: [Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")] ...
-1
votes
0answers
36 views

unable to connect MSSQL using pyodbc

I have already looked up a lot of some what similar questions on StackOverflow regarding the connectivity of MSSQL with pyodbc, but none of their solutions helped. I'm tring to connect a MSSQL ...
0
votes
1answer
31 views

How to convert hex form dataframe to human readable form in python

I am trying to fetch varbinary form of data from mssql server and convert it into readable form. def fetchdata(self): query = 'select * from xlstorage' df = pd.read_sql(query, self.conn) ...
0
votes
0answers
19 views

Returning list of list into Datalist input

I have list of companies in my database , which contain for each company the following data : Company_name , Bank_name,Account_id,Currency I have an HTML5 page which a user has two inputs to choose ...
0
votes
1answer
36 views

Connect from python3 - pyodbc (linux) to a firebird 2.5 (windows) ODBC DSN on remote machine

I am trying to connect to a customer's DB via ODBC. The ODBC DSN was setup on the the Windows machine. I don't know the path to the DB or the DB name so I have to rely on the DSN. From what I've seen ...
0
votes
1answer
28 views

Create table and insert two records SQL using python

I'm trying to create a table on a tempdb database on a local server KHBW001 using MSSQL. My code is: import pyodbc connection = pyodbc.connect('Driver={SQL Server};' 'Server=...
0
votes
0answers
37 views

from sql server to pandas dataframe with pyodbc - while working with small tables, it gives an error on complex sql queries

1 step: Create a temporary table with pyodbc into sql server for objects 2 step: Select objects from temporary table and load it into pandas dataframe 3 step: print dataframe for creating a temporary ...
0
votes
1answer
27 views

loading floats into SQL server using executemany in python

I am reading in some sensor data from a source that gives me a list of floats. example: sensor_data = [1.1, 2.2, 1.3, 2.5] I want to load these values using pyodbc's "execute_many" function; ...
1
vote
1answer
101 views

How to fix 'Can't open libmsodbcsql-17.3.so.1.1'

In ubuntu 19.04 when working with Python3 in an anaconda environment with pyodbc 4.0.26 installed I get the Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/...
1
vote
0answers
53 views

Problem installing PyODBC for local debugging with AWS SAM CLI

I'm developing a lambda function in Python. The function access RDS database using the pyodbc library. To work with the library I'm using layers. My SAM template looks like this and everything works ...
2
votes
1answer
45 views

Pass a Python list to the ORDER BY clause of a SQL Server query

I am trying to pass a python list to a SQL Server query. I am having trouble with pyobdc errors. I have tried the following: # order_by is a list with 80 strings e.g. ['a','b','c', ...] placeholders ...
0
votes
0answers
33 views

Pyodbc connect SQL server failed once change SQL server authentication into Azure Active Directory Authentication in Ubuntu

Pyodbc connect SQL server failed once change SQL server authentication into Azure Active Directory Authentication in Ubuntu I write connection string through the official website: https://docs....
0
votes
2answers
58 views

executemany: Failed executing the operation; Could not process parameters (Python)

I've written a bit of python code that essentially will take data from one database (SQL Server 2008) and insert it into another (MySQL). I am fairly new to python so am struggling to find the errors ...
0
votes
1answer
19 views

Sporadic semaphore timeout using SQL Server 2014 and pyodbc

I have this strange semaphore timeout issue when inserting into SQL Server. Below is a short snippet of code that can reproduce the issue. None of my colleagues running the same code base have issues ...
0
votes
0answers
26 views

Formatting Print Output in Python 3.7

I have a connection to a MSSQL database with pyodbc and im looking to format the results into a table, I have tried prettytable without good results (it put my headers on 2 rows and was still jumbled ...
0
votes
2answers
33 views

Needing help adding a variable in a sql query within Python

I am trying to write a while loop within my sql query in python but have had some trouble. The variable I want is my 'count' to be included in the records when inserting values. The code below is ...
1
vote
1answer
26 views

How to use pyodbc, cursor, execute to extract data from SQL when there is no parameters for query.format?

Usually, I use the following way to extract data from SQL using python: myConnect=pyodbc.connect('DSN=B1P HANA;UID=****;PWD=****') myCursor=myConnect.cursor() Start1=20150101 End=20200101 query = """...
0
votes
1answer
23 views

Having trouble connecting to an mssql database using sqlalchemy

I am trying to connect to a database and insert into it using sqlalchemy. I have already succesfully connected to the database using pyodbc but sqlalchemy is giving me trouble. I am using sqlalchemy ...
1
vote
2answers
30 views

Parametrizing TOP value in tsql and pyodbc

I try to parametrize number of top rows to get from table. I tried it with db.cursor.execute( ''' SELECT TOP ? VALUE FROM mytable WHERE param = ? ''', ...
0
votes
0answers
20 views

How to insert column headers and data from PANDAS dataframe into MS-Access by PYODBC SQL query

I have the following code that manipulates the data and I should insert it into existing table with the same structure. It gives me an error that is in the INSERT query: Traceback (most recent call ...
0
votes
0answers
20 views

Spark ODBC driver connection getting failed

I have configured spark odbc driver on Azure Virtual Machine. Created a System DSN for Azure Databricks connection. Connection was successful and I can connect to databases. After query execution for ...
1
vote
1answer
54 views

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 ...
0
votes
0answers
28 views

“Login timeout expired” when trying to access MSSQL db from django

My django app was working on sqlite3 database. Few days ago I got a "mission" to make the app using mssql. And I can't connect to database. My settings.py looks like this: DATABASES = { '...
1
vote
1answer
33 views

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 ...
0
votes
0answers
39 views

Login failed for user while connecting to mssql using pyodbc

I am trying to connect to mssql using pyodbc in python and I am using MacOs Mojave. I write the code to make the connection but it gives me the Login failed for user, though I am pretty sure the user ...
0
votes
0answers
27 views

Get pandas dataframe headers and create new Access table with them

I have the following issue. I am creating offline ACCESS tool and many times I have to create an Access CROSSTAB that has undefined number of columns requiring manipulation of data in fields beyond ...
0
votes
3answers
37 views

Is there a way of aggregating rows without summing up their results?

My DataFrame consists of 2 columns. One with a patient's id and one with a patient's problem. I need to create a DataFrame in which all problems of a patient are in one row with the corresponding ...
1
vote
1answer
92 views

[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 ...
1
vote
1answer
23 views

“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 ...
0
votes
0answers
32 views

Querying Access database through pyodbc sometimes works fine, but sometimes gives connection error

I am trying to execute SQL query in a locally stored Access database through pyodbc. In the code below, printing the table names works fine, so the connection seems to be established successfully: ...