pyodbc

What's causing 'unable to connect to data source' for pyodbc?

送分小仙女□ 提交于 2019-11-30 03:00:57
I'm trying to connect to an MSSQL database from python on Linux (SLES). I have installed pyodbc and Free TDS. From the command line: tsql -H server -p 1433 -U username -P password Connects to the server without a problem, however, from Python: import pyodbc pyodbc.connect(driver='{FreeTDS}', server='server', database='database', uid='username', pwd='password') Yields an error: pyodbc.Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)') I'm finding this error unhelpfully vague. Even a suggestion to narrow down the issue would be

Common ways to connect to odbc from python on windows? [closed]

牧云@^-^@ 提交于 2019-11-30 01:40:47
What library should I use to connect to odbc from python on windows? Is there a good alternative for pywin32 when it comes to odbc? I'm looking for something well-documented, robust, actively maintained, etc. pyodbc looks good -- are there any others? You already suggested pyodbc , and I am going to agree with you. It has given me the least amount of issues in my experience; I've used pymssql and adodbapi , and when those threw exceptions/created issues, I swapped out the code and replaced it with pyodbc and it either fixed the problem, or gave better error messages so I could debug faster. It

Connecting to SQL Server 2012 using sqlalchemy and pyodbc

淺唱寂寞╮ 提交于 2019-11-30 01:03:42
I'm trying to connect to a SQL Server 2012 database using SQLAlchemy (with pyodbc) on Python 3.3 (Windows 7-64-bit). I am able to connect using straight pyodbc but have been unsuccessful at connecting using SQLAlchemy. I have dsn file setup for the database access. I successfully connect using straight pyodbc like this: con = pyodbc.connect('FILEDSN=c:\\users\\me\\mydbserver.dsn') For sqlalchemy I have tried: import sqlalchemy as sa engine = sa.create_engine('mssql+pyodbc://c/users/me/mydbserver.dsn/mydbname') The create_engine method doesn't actually set up the connection and succeeds, but

pyodbc insert into sql

假如想象 提交于 2019-11-29 23:56:49
I use a MS SQL express db. I can connect and fetch data. But inserting data does not work: cursor.execute("insert into [mydb].[dbo].[ConvertToolLog] ([Message]) values('test')") I get no error but nothing is inserted into the table. Directly after I fetch the data the inserted row is fetched. But nothing is saved. In MS SQL Server Management Studio the insertion does work. You need to commit the data. Each SQL command is in a transaction and the transaction must be committed to write the transaction to the SQL Server so that it can be read by other SQL commands. Under MS SQL Server Management

Python pip unable to locate pyodbc

旧巷老猫 提交于 2019-11-29 22:57:57
Using virtualenv and just trying to install pyodbc. All resources I can find claim this should be extremely straightforward. After all the basic installs of MySQL, etc., just do: pip install pyodbc However, I am seeing a very strange error. It has nothing (as far as I can tell) to do with missing libraries, and after Googling for this sort of error for a long time, I can't find anything constructive on it at all. (local-dev)espears@espears-w ~ $ pip install pyodbc Downloading/unpacking pyodbc Could not find any downloads that satisfy the requirement pyodbc Some externally hosted files were

Installing pyodbc fails on OSX 10.9 (Mavericks)

这一生的挚爱 提交于 2019-11-29 19:06:10
When running pip install pyodbc , I get In file included from .../build/pyodbc/src/buffer.cpp:12: .../build/pyodbc/src/pyodbc.h:52:10: fatal error: 'sql.h' file not found #include <sql.h> ^ 1 error generated. error: command 'cc' failed with exit status 1 It seems that Mavericks has no sql.h under /usr/include Did anyone manage to install pyodbc? Is there a known workaround? As you noticed OSX Mavericks dropped sql headers that are required for PyODBC compilation. Following these steps allowed me to install PyODBC: Make sure you have iODBC library installed ( http://www.iodbc.org/ ) Download

How to get datatypes of specific fields of an Access database using pyodbc?

不想你离开。 提交于 2019-11-29 17:32:33
I'm using pyodbc to data-mine a big database in a .mbd (access) file. I want to create a new table taking relevant information from several existing tables (to then feed it to a tool). I think I know all I need to transfer the data, and I know how to create a table given column names and datatypes, but I'm having trouble getting the datatypes (INTEGER, VARCHAR, etc.) of the respective columns in the existing tables. I need these types to create the new columns compatibly. What I found on the internet (like this and this ) is getting me into invalid-command trouble, so I think this is a

pyodbc: How to retry to recover from Transient errors?

纵然是瞬间 提交于 2019-11-29 16:16:32
I've an API hosted on Flask. It runs behind a Tornado server. What is happening is that sometimes changes made on the UI are not reflected in the database. Also a few of the scripts I have running gives any of the 3 following errors: pyodbc.Error: ('08S01', '[08S01] [Microsoft][ODBC SQL Server Driver]Communication link failure (0) (SQLExecDirectW)') pyodbc.Error: ('01000', '[01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionWrite (send()). (10054) (SQLExecDirectW)') pyodbc.Error: ('01000', '[01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (recv()). (10054)

pyodbc + MySQL + Windows: Data source name not found and no default driver specified

百般思念 提交于 2019-11-29 14:03:27
问题 I am trying to connect to MySQL 5.6 on a Windows Server 2008 R2 localhost with pyodbc. I used the full installation for the MySQL instance on the localhost, including the ODBC connector. I have it connecting to a remote SQL Server instance beautifully, but for the life of me I can't get it to connect to the local MySQL instance. I am using this guide from connectionstrings.com as reference. Here's some code: import pyodbc def create_mssql_conn(): return pyodbc.connect(r'Driver={SQL Server}

Using pyodbc cause error: Data source name not found and no default driver specified

与世无争的帅哥 提交于 2019-11-29 12:20:00
I'm using pyodbc to connect SQL Server. I had created connection string like this: from sqlalchemy import Table, Column, databases, Integer, String, ForeignKey, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import session engine = create_engine('mssql+pyodbc://sa:123@localhost/TrainQuizDB') engine.connect() TrainQuizDB is database name that I created in Sql Server. For more information I have windows 8.1 64bit and I installed python version 3.5.1 32bit and I downloaded pyodbc from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyodbc (pyodbc-3.0.10-cp35