pyodbc

Syntax for a parameter query in Python (pyodbc)

我只是一个虾纸丫 提交于 2019-11-28 14:47:21
I am trying to write results of some processing into SQL Server table. My results are store in a list of lists where each item of the list is a list. I am using parameters (6 params) and I am getting the following error: cnxn.execute(sqlStatement, (item[0],item[1],item[2],item[3],item[4],item[5])) pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 6 parameters were supplied', 'HY000') That's my code sqlStatement = "INSERT INTO CEA_CR (`SessionID`, `Session.Call_TYPE_Assigned`, `Session.Did_Call_Type_happen_on_this_call`, `Session.Was_there_a_system_or_Rep_generated_Memo_that

pyodbc requires python 3.3

99封情书 提交于 2019-11-28 14:40:12
I just downloaded installer for pyodbc from google project . I have Python 3.5 istalled and pyodbc requires 3.3. Is there an easy work around? P.S. I am installing it on PC without Internet access. This is for Windows. Since you can't install this via the regular pip channels, you can download a prebuilt binary for Python 3.5 from Chris Gohlke's site , where he has a bunch of libraries he creates builds for. Download either depending on the version of Python 3.5 you have installed: pyodbc‑3.0.10‑cp35‑none‑win32.whl if you have a 32-bit Python 3.5 install pyodbc‑3.0.10‑cp35‑none‑win_amd64.whl

How can i connect to local advantage database using pyodbc in python?

微笑、不失礼 提交于 2019-11-28 14:29:22
As far as i can understand to use pyodbc you have to cnxn = pyodbc.connect('DRIVER={Advantage ODBC Driver};SERVER=local;DataDirectory=\\AltaDemo\Demo\AltaPoint.add;DATABASE=AltaPoint;UID=admin;PWD=admin;ServerTypes=1;') cursor = cnxn.cursor() This is the error i get from the console when i run this Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') The name of the driver is Advantage StreamlineSQL ODBC , so the bare minimum connect string is: DRIVER={Advantage StreamlineSQL ODBC};DataDirectory=D:\Temp

Installing pyodbc fails on OSX 10.9 (Mavericks)

…衆ロ難τιáo~ 提交于 2019-11-28 14:27:40
问题 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? 回答1: As you noticed OSX Mavericks dropped sql headers that are required for PyODBC compilation. Following these steps

Python inserts a colon in a Decimal number from Access via pyodbc

偶尔善良 提交于 2019-11-28 13:43:05
I'm having the same problem as this guy and possibly this guy , but I am around to share some code and respond to questions! I have some code in a batch job that reads fields from a Microsoft Access database via pyodbc and prepares the output for display. Here is a snippet. Note the assert. def format_currency(amount): if amount is None: return "" else: result = "$%.2f" % amount assert ":" not in result, ( "That's weird. The value %r of class %s is represented as %s" % (amount, amount.__class__, result)) return result When I run it, it successfully processes 100,000 rows and then fails:

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

此生再无相见时 提交于 2019-11-28 12:51:24
问题 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

“CREATE … statement not allowed within multi-statement transaction” when using pyodbc

£可爱£侵袭症+ 提交于 2019-11-28 12:32:44
I'm trying to create a SQL Server database using pyodbc. import pyodbc server = 'AMR112\NAMED1' database = 'msdb' username = '' password = 'mypassword' abcd='yes' ghi='False' #driver = '{/usr/local/lib/libtdsodbc.so}' #for linux of windows driver= '{ODBC Driver 13 for SQL Server}' cnxn = pyodbc.connect('DRIVER='+driver+';PORT=1433;SERVER='+server+??';PORT=1443;DATABASE??='+database+';UID='+??username+';PWD='+ password+';trusted_connection='+ abcd+'; autocommit='+ ghi) cursor = cnxn.cursor() cursor.execute("create database dbafgh") row = cursor.fetchone() if row: print row cursor.close() It

ODBC Driver 13 for SQL Server can't open lib on pyodbc while connecting on AWS E2 ubuntu instance

南楼画角 提交于 2019-11-28 10:13:29
Background: i have been at it for about a week but still no luck. the same driver (13.0) on my system (Ubuntu 16.04.1 LTS) works just fine with my pyodbc python (Python 2.7.12 :: Anaconda 4.1.1 (64-bit)) library. i tried setting up a virtual machine on AWS E2 but it does not work there as described below. Objective: Connect to Azure SQL Server using Python 2.7.12 :: Anaconda 4.2.0 (64-bit) with official ODBC Driver from Microsoft on Amazon Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64) Problem: I have tried connecting pyodbc to azure sql using the ODBC official ODBC driver 13 from

pyodbc: How to retry to recover from Transient errors?

爱⌒轻易说出口 提交于 2019-11-28 09:33:43
问题 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:

SQL IN operator using pyodbc and SQL Server

允我心安 提交于 2019-11-28 08:39:26
I'm using pyodbc to query to an SQL Server database import datetime import pyodbc conn = pyodbc.connect("Driver={SQL Server};Server='dbserver',Database='db', TrustedConnection=Yes") cursor = conn.cursor() ratings = ("PG-13", "PG", "G") st_dt = datetime(2010, 1, 1) end_dt = datetime(2010, 12, 31) cursor.execute("""Select title, director, producer From movies Where rating In ? And release_dt Between ? And ?""", ratings, str(st_dt), str(end_dt)) but am receiving the error below. Does the tuple parameter need to be handled in a different way? Is there a better way to structure this query? ('42000'