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

Inner join query from SQL Server and Oracle with Python

Let's say I have a query like such: SELECT Oracle.Column1, SqlServer.Column1 FROM SqlServer INNER JOIN Oracle on SqlServer.ID = Oracle.ID I have established cursor connections in python to their respective databases using Cx_Oracle and pyodbc.…
thisguy
  • 57
  • 1
  • 8
1
vote
1 answer

Connect to remote MSSQL 2016 using isql and python on Mac?

Goal: Connect to remote MSSQL 2016 server via Python. Main approach: Closely followed tutorial in https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Mac-OSX . Problem: Able to connect via tsql, but isql is not working.…
1
vote
1 answer

TypeError: object of type 'map' has no len() when trying to insert a CSV into an SQL Server database in Python 3

So I'm trying to get a CSV file into an SQL Server, sample csv file STUFF,NAME,A DATE,A TIME,ANOTHER DATE,ANOTHER TIME,A NUMBER Bananas John Smith,2019-11-20,17:00,2019-11-20,20:00,3 Apples,Jane Doe,2019-11-07,17:00,2019-11-07,23:00,6 here's how…
츄 plus
  • 488
  • 1
  • 7
  • 20
1
vote
1 answer

Cannot create database with SQLAlchemy with SQL Server

Please note that I have been attempting to create a new database using SQLAlchemy, but have gotten many errors where I am attempting to work with laravel and vagrant. Thankfully I have been able to create a new database using pyodbc, but ultimately…
user8128167
  • 6,929
  • 6
  • 66
  • 79
1
vote
1 answer

Executing Dynamic SQL using Python but receiving exceptions

I have below dynamic SQL script which runs on SQL Server with no issues. DECLARE @file_type_id int = 1, @filing_id bigint = 57, @created_at datetime = GETDATE(), @created_by bigint = 2, @is_required bit = 1, @insertquery nvarchar(MAX), @Filepath…
user2961127
  • 963
  • 2
  • 17
  • 29
1
vote
1 answer

Python 3.0 Import Excel file to Access File

I have used Python 3 to create an Excel (.xlsx) file. Now I want to convert this Excel file to an Access (.accdb) file. I know Access can import Excel file, but I am trying to use Python to automate this. There are 3 sheets in the Excel file. I…
nseiong
  • 13
  • 3
1
vote
0 answers

Adaptive Server Enterprise on Docker container

I managed to install FreeTDS driver in a python:3.7-alpine container, now I want to add Adaptive Server Enterprise driver. I need it because I need to run queries on a Sybase db in order to populate the PostgreSQL db on my Django app. Anyone knows…
jordi588
  • 37
  • 7
1
vote
0 answers

Connect Raspberry Pi to SQL Server using pyodbc error: [08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)

I'm trying to connect a raspberry pi 3 to a local SQL Server. I did this: sudo apt-get install unixodbc sudo apt-get install unixodbc-dev sudo apt-get install freetds-dev sudo apt-get install tdsodbc sudo apt-get install freetds-bin sudo pip3…
altdave
  • 108
  • 1
  • 10
1
vote
0 answers

Running transact SQL (t-sql) block in python using pyodbc

I have the below set of T-SQL statements. Where a cursor is loaded with about 500 IDs. And for each ID a set up update statements are executed. declare @id int declare @ids cursor set @ids=cursor fast_forward read_only for select id…
nJoshi
  • 376
  • 1
  • 5
  • 16
1
vote
1 answer

pyodbc: multiple connection issues, DML statements in .ipynb files not reflected in SQL Server

I am using pyodbc to connect to a database on my local machine. I have two .ipynb files that are responsible for populating two of the relations in this database respectively. There are two observations I have made that are troubling: If one a…
omri
  • 352
  • 2
  • 18
1
vote
1 answer

Connect to Linked Server via SQL Server pyodbc connection?

I can currently connect to my SQL Server and query any database I want to directly. The problem is when I want to query a linked server. I cannot directly reference the linked servers name in the connect() method and I have to connect to a local…
Mike - SMT
  • 14,784
  • 4
  • 35
  • 79
1
vote
0 answers

Teradata connection string using Windows Authentication

I am using Python3.6 and pyodbc to try and connect to Teradata. I need this for a script I want to hand off to an end user to update from data. I would prefer that each user not have to be instructed to setup their own DSN connection with a specific…
brian_ds
  • 317
  • 4
  • 12
1
vote
1 answer

Connecting to IBM DB2 using CLI and SSL

I was using JDBC to connect to IBM DB2 AS400 for iSeries in my Rails Application. Now it looks like I will have to move to use the ibm_db gem. https://github.com/ibmdb/ruby-ibmdb I attempted this with irb first and used the following in a command…
user3437721
  • 2,227
  • 4
  • 31
  • 61
1
vote
1 answer

ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '@P1'. (102)

Here is my code. I am getting error at 'BULK INSERT' statement. Please tell why the bulk insert is not working: local_path="C:\\Users\\sankalp.patil\\assignment\\upload" block_blob_service = BlockBlobService(account_name='samplsa',…
sankalp
  • 11
  • 1
  • 1
  • 3
1
vote
1 answer

What is the fastest and most efficient way to check database for new entry?

I currently have an application that, at any given time, will INSERT new data into my database. I also have a different python script that checks my database in an infinite loop for a new entry, and when it finds one, it selects it, and uses it,…