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
0 answers

DataError: (pyodbc.DataError) ('String data, right truncation: length 6454 buffer 6452', '22001') [SQL: u'INSERT INTO

With the help of python3, pandas and pyodbc (version 4.0.24), we are tying to upload a data frame with a column "Review" with usually large amounts of text in it. In the middle of the upload process we get the below error: DataError:…
1
vote
0 answers

How can I install unixODBC without brew?

I am trying to use the pyodbc package in Python 3.6, but get an image error. Upon researching, some have suggested that Macs require a unixODBC package to fix the error. I don’t have access to use brew. Is it possible to install unixODBC with pip or…
Insu Q
  • 403
  • 6
  • 13
1
vote
1 answer

I can't update database from python

I have an sql table which i want to update based on a function this is my code so far: def read(conn): cursor = conn.cursor() #cursor2 = conn.cursor() cursor.execute("SELECT All [id],[keyword],[result],[status],[createddate] FROM…
hadesfv
  • 386
  • 4
  • 18
1
vote
2 answers

GCP Cann't deploy with install pyodbc

I'm try to use GCP (Google cloud platform) : API Service with python project. And this project need to use lib : pyodbc for connect to MSSQL. In localhost it fine but when I try to deploy this project to GCP it show error like this. Can someone help…
bigeyesowl
  • 13
  • 3
1
vote
1 answer

Return an iterator with python pyodbc

I'm trying to write a DataAccessLayer with python. One of the functions should return an iterator for a large set of rows(i don't want to fetch all and eat a lot of memory). The iterator will be used in another class that is using my DAL class to…
Cony
  • 213
  • 1
  • 8
  • 21
1
vote
0 answers

SQL Server: pypodbc inserting empty values

I have code with following insert statement. cursor = self.conn.cursor() print("New config with values: {0}, {1}".format(self.scale_factor, self.min_neighbours)) cursor.execute("INSERT INTO config(scale_factor, min_neighbours)…
Michalides
  • 152
  • 1
  • 8
1
vote
0 answers

Python Azure SQL - 'ODBC Driver 17 for SQL Server' : file not found

I have to connect my script to a MSSQL hosted on Azure. I followed this tutorial from Microsoft : https://www.microsoft.com/en-us/sql-server/developer-get-started/python/mac/step/2.html I adapted it a bit for my need but the connection part is the…
Ragnar
  • 2,550
  • 6
  • 36
  • 70
1
vote
0 answers

Type clash: image is incompatible with varchar(max)

I would like to save html in SQL Server. From the discussions I have seen in stackoverflow (Storing HTML in SQL Server), the recommendation is to use NVARCHAR(MAX) or VARCHAR(MAX) However, when I try to save html in the VARCHAR(MAX) Or NVARCHAR(MAX)…
1
vote
1 answer

Python:3.7-stretch unixodbc : Conflicts: unixodbc-bin

I have a Python Flask application running in a Docker container that connects to MS SQL Server (a corporate database) via SQLAlchemy. However, I am getting package conflicts when I try to build the container. Here is my Dockerfile: FROM…
Merkidemis
  • 2,801
  • 2
  • 20
  • 26
1
vote
1 answer

How to pass the driver parameter to sqlalchemy when using the creator parameter of create_engine

I have a pyodbc connection object using the keyword functionality of pyodbc.connect() (https://github.com/mkleehammer/pyodbc/wiki/Module#connect). The keywords include a driver parameter: conn = pyodbc.connect(driver="SQL Server",…
Tom Malkin
  • 2,134
  • 2
  • 19
  • 35
1
vote
0 answers

How to solve the user connection problem when using the framework pyodbc in Ubuntu 16.04 machine?

Solved!!! I am trying to connect with a local SQL Server database using the Python framework 'pyodbc' in an Ubuntu machine. But I get over and over the same error. As background I have to add that I first createn locally a database with the…
Salvador Vigo
  • 397
  • 4
  • 16
1
vote
0 answers

SyntaxError: EOL while scanning string literal while executing query

I'm trying to execute this Python code in Jupyter Notebook, but I'm getting this error. import pandas as pd import pyodbc query = "SELECT [CodeClient] ,[Nom] ,[Adresse],[CodePostal],[Telephone],[Fax],[Remarque], …
user9934696
1
vote
1 answer

Pyodbc IM002 database connection

I have successfully connected to this database many times before, but just now I have encountered this error: pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0)…
Morgan
  • 71
  • 1
  • 2
  • 8
1
vote
1 answer

Django 2.0+ and SQL Server interface question

Why is it necessary to have both Pyodbc and django-pyodbc-azure installed to interface with recent SQL Server versions with Django? Why can't django just use Pyodbc out of the box? I'm having trouble getting Sql Server to play nice with python…
Jasonca1
  • 4,848
  • 6
  • 25
  • 42
1
vote
0 answers

pyodbc customized converter

When writing the customized the converter in pyodbc, how to call the default converter? I am interested in customize the SQL_DECIMAL data type conversion and have the trailing zero stripped. I am thinking the 2 following options: 1) calling the…
fivelements
  • 1,487
  • 2
  • 19
  • 32
1 2 3
99
100