Comments (3)
Have you tried querying with tsql and isql?
This may not be pyodbc issue. I had this problem with selecting with unicode parameter and I've installed from sources freetds 0.91, unixODBX 2.3.0 and latest pyodbc.
quoting http://groups.google.com/group/sqlalchemy/browse_thread/thread/971e068032d51dd5 this is what has worked for me on ubuntu 10.04
unixODBC
First I removed system packages unixODBC and unixODBC-dev (names may
vary by Linux distro). Then
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz
tar zxvf unixODBC-2.3.0.tar.gz
cd unixODBC-2.3.0
./configure
make
sudo make install
As root ensure that /usr/local/etc/odbcinst.ini has the following
entries:
[FreeTDS]
Driver = /usr/local/lib/libtdsodbc.so
[SQLServer]
Driver = /usr/local/lib/libtdsodbc.so
The second entry is for aesthetics only - so you can use "SQLServer"
in your connection strings. Odbc.ini file is not important if you use
fully qualified host names in your connection string but at your
option you may configure DSNs there.
FreeTDS
Also uninstall any system packages that you may have for this, then:
wget http://www.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar xvf freetds-stable.tgz
cd freetds-0.91
./configure --with-unixodbc=/usr/local --enable-msdblib --with-
tdsver=8.0
make
sudo make install
Remove or otherwise disable /etc/freetds.conf if any. Modify /usr/
local/etc/freetds.conf to read as follows:
[global]
# TDS protocol version
tds version = 8.0
client charset = UTF-8
# This is probably not needed...
text size = 64512
# Typical SQLServer
[server_name]
host = hostname.somedomain
port = 2431
tds version = 8.0
At this point you should be able to login successfully using:
tsql -S server_name -U username -P password
or
isql Database username password
Pyodbc
git clone https://github.com/mkleehammer/pyodbc.git
python setup.py bdist_egg
cd dist
easy_install pyodbc-3.0.2_beta01-py2.6-linux-i686.egg # filename may vary based on architecture
#pyodbc_sand.py
import pyodbc
con = pyodbc.connect('DSN=Northwind; UID=vte; PWD=vte')
sqlstr = "select * from Customers where CustomerID = (?)"
cur = con.cursor()
q = cur.execute(sqlstr, u'ĄŁÓ$!')
res = q.fetchall()
print res
#output: [(u'\u0104\u0141\xd3$!', u'URL Encoders', None, None, None, None, None, None, None, None, None)]
from pyodbc.
Look at my pull request, I suspect it's relevant. I have had the same issue with Virtuoso and solved it with
settings['extra_compile_args'].append('-DSQL_WCHART_CONVERT=1')
from pyodbc.
If you use the default unixODBC build (2-byte UCS2) this should now work on 3.0.10 (not built yet). Can you try the master branch and confirm?
from pyodbc.
Related Issues (20)
- Add support for SQLTablePrivileges
- Login Timeout Error when connecting to Synapse database using pyodbc python library in Azure synapse notebook via Managed Identity HOT 1
- reference count encoding in the connect function HOT 5
- PyToCType uses internal function removed from Python 3.13 HOT 3
- I am trying to install pyodbc in MacBook Pro M3 chip - arm64. The drivers are installed succesfully for odbc 13,17 and 18. But pyodbc is not able to detect the drivers.:
- I am trying to install pyodbc in MacBook Pro M3 chip - arm64. The drivers are installed succesfully for odbc 13,17 and 18. But pyodbc is not able to detect the drivers. ERROR: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)") HOT 5
- Executing multiple queries HOT 1
- pyodbc.connect() gives an error when executing it with pytest HOT 1
- InterfaceError: Data source name not found with pyodbc despite working with isql HOT 8
- Multiple threads querying same table takes a long time HOT 19
- Timeout not being enforced in SQL query HOT 7
- How to use Federated credentials with service principal to auth the Azure resources HOT 7
- Ansi to Unicode conversion error (noob) HOT 9
- How to surface azure active directory service principal related errors HOT 3
- Do we need to close cursor in this case? HOT 9
- Connection pooling broken in 5.1.0 or 5.0.1 (with unixODBC 2.3.12)? HOT 3
- pyodbc.Connection' object has no attribute 'columns'
- Can't connect to Microsoft Access in 5.1.0 HOT 4
- Memory allocation error when inserting string of size 128 HOT 6
- SSMS shows "Restoring..." message after this restore command executed from pyodb/python3 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyodbc.