pyodbc

pyodbc: ('Params must be in a list, tuple, or Row', 'HY000') with NumPy data

蓝咒 提交于 2019-12-11 00:14:56
问题 I am trying to insert a list of tuples into an MS SQL table via pyodbc with Python 3. This works: conn_string = (('DRIVER=FreeTDS;' 'SERVER={};' 'PORT=1433;' 'DATABASE={};' 'UID={};' 'PWD={};' 'TDS_Version=8.0;') .format(server, db, user, pwd)) sql = """ insert into Table1(field1, field2, field3) values (?, ?, ?) """ cursor.executemany(sql, [('1175B57E-7A10-4BAC-B22E-457C8266C0F2', '1D111FA5-A65D-4F77-A3AB-78B80BAF0C0B', 2), ('C60FA1C9-7656-4EBF-A577-44CBF0C641F4', '365FB706-9F7F-4ED4-AB88

python - connecting to a database with pyodbc - not working

淺唱寂寞╮ 提交于 2019-12-10 23:50:45
问题 I am trying to connect to an Access 2007 database with the following connection string. conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=<C:\Users\JSeinfeld\Desktop\Backup databases\Database_6.7.accdb>;") I get this error: Traceback (most recent call last): File "", line 1, in conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=;") Error: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key

Can I use pyodbc/freetds and sqlalchemy with decimal data in mssql?

痞子三分冷 提交于 2019-12-10 22:58:36
问题 This has been a long running issue for me. I have a proprietary database that I cannot change and many of the tables have fields which are defined as e.g. decimal(12, 4). When I try to pull data from such a table on ubuntu 12.04 using pyodbc/freeTDS like this... import pyodbc connection_string = 'DRIVER={FreeTDS};DSN=<myDSN>;UID=<my_user>;PWD=<my_password>;' conn = pyodbc.connect(connection_string) cur = conn.cursor() cur.execute('SELECT myfield FROM mytable') for row in cur.fetchall(): print

pyODBC: specify location of driver in Windows

最后都变了- 提交于 2019-12-10 21:43:21
问题 Is it possible to specify where pyodbc looks for the SQL driver? I have a python application which needs the 'SQL Native Client 10.0' driver to connect to a SQL database. So my connection string looks like: dsn = 'DRIVER={SQL Server Native Client 10.0};SERVER=localhost;DATABASE=mydatabase;UID=sa;PWD=mypasswd' con = pyodbc.connect(dsn) with con: #do something One major disadvantage (at least for me) is, that the SQL Native Client 10.0 driver needs to be installed on the machine and that

Python - insert into ms access table

久未见 提交于 2019-12-10 19:48:44
问题 I am able get some data from the ms access by some query, but I am not able to store data into any table, for example: import sys, os, pyodbc conn_str = ( r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};' r'DBQ=C:/Users/vlcek/Desktop/pokusdb.accdb;' ) connection = pyodbc.connect(conn_str) cursor = connection.cursor() sql="Insert into people (user_id, Name, Surname) values (27, 'Peter','Jackson')" cursor.execute(sql) I do have the table "people" already in database... I am getting this

Python Dictionary Contains Encoded Values

廉价感情. 提交于 2019-12-10 19:07:50
问题 I have a pandas data frame oParameterData which I have built querying on Hadoop using Hive ODBC connection. I am using it to populate a Python dictionary called oParameter import pyodbc import pandas oConnexionString = 'Driver={ClouderaHive};[...]' oConnexion = pyodbc.connect(oConnexionString, autocommit=True) oConnexion.setencoding(encoding='utf-8') oQueryParameter = "select * from my_db.my_table;" oParameterData = pandas.read_sql(oQueryParameter, oConnexion) oCursor = oConnexion.cursor()

Pyodbc - The specified DSN contains an architecture mismatch between the Driver and Application

安稳与你 提交于 2019-12-10 18:45:44
问题 I'm trying to connect to a MS Access Database (.accdb file) via python. I used pyodbc to do this connection: import pyodbc conn = pyodbc.connect("DRIVER = {Microsoft Access Driver (*.mdb, *.accdb)}; DBG=C:\\test_db.accdb") However, I got the following error: ('IM002, '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') I went to the ODBC Data Source Administrator and when I tried to configure or remove the Driver I got

pandas + pyodbc ODBC SQL type -150 is not yet supported

我怕爱的太早我们不能终老 提交于 2019-12-10 17:51:30
问题 I know there is many topics on this but i think this is much specific. I get the current code for audit purpose: import pandas as pd import pyodbc query = """ --Top 50 high total CPU Queries SELECT TOP 50 'High CPU Queries' as Type, serverproperty('machinename') as 'Server Name', isnull(serverproperty('instancename'),serverproperty('machinename')) as 'Instance Name', COALESCE(DB_NAME(qt.dbid), DB_NAME(CAST(pa.value as int)), 'Resource') AS DBNAME, qs.execution_count as [Execution Count], qs

Accessing a local SQL Server 2008 database with pyodbc on Windows 7

假如想象 提交于 2019-12-10 17:41:22
问题 I'm trying to use pyodbc to connect to a local copy of a SQL Server 2008 database (it connects to the remote production database just fine). However, when I try connecting to the local copy using the following command: pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=mydb;UID=me;PWD=pw') the connection fails with the following error message: pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17)

PYODBC does not like %, “The SQL contains 2 parameter markers, but 1 parameters were supplied.”

一个人想着一个人 提交于 2019-12-10 17:24:47
问题 So I'm currently linking Python with SQL to pull out customer information. Unfortunately, I'm getting some errors with regards to SQL. I am trying to use the LIKE operator, and the % wildcard, but I keep getting errors because Python does not like %. As a result, it pretends that variable between the %s do not exist. Here's what I mean: SELECT custnbr, firstname, middleint, lastname FROM lqppcusmst WHERE custnbr = ? AND firstname LIKE ? Right now, I'm just testing it out, so I'm just using