pyodbc

How to create permanent MS Access Query by Python 3.5.1?

我与影子孤独终老i 提交于 2019-12-01 23:51:38
问题 I have about 40 MS Access Databases and have some troubles if need to create or transfer one of MS Access Query (like object) from one db to other dbs. So I tried to solve this problem with pyodbc but.. as I saw pyodbc doesn't support to create new, permanent MS Access Query (object). I can connect to db, create or delete tables/rows but can't to create and save new query. import pyodbc odbc_driver = r"{Microsoft Access Driver (*.mdb, *.accdb)}" db_test1 = r'''..\Test #1.accdb''' db_test2 = r

Python truncate at 255 chars when querying MS SqlServer with FreeTDS

梦想的初衷 提交于 2019-12-01 23:33:17
i think i have miss something in a query from python using pyodbc over a FreeTDS on a Debian machine. I can not manage to have more than the first 255 characters. if i try to CAST SQL data as describe here: ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS) with : SELECT CAST(myText as TEXT) FROM mytable i get empty/zero length string, i have also test with no more success to : change size as describe with the config below, i only get first 255 characters (while on my Win box pyodbc can get 279 characters, for example). here is a sample query : SET TEXTSIZE

Connect Python to Teradata in mac with pyodbc

廉价感情. 提交于 2019-12-01 23:02:40
I successfully installed pyodbc module for python 2.7. However, when input the following code to connect to teradata, import pyodbc conn = pyodbc.connect('DRIVER={Teradata};DBCNAME=<tdwc>;UID=<UID>;PWD=<UID>;QUIETMODE=YES;') I got the following error; Traceback (most recent call last): File "", line 1, in pyodbc.connect('DRIVER={Teradata};DBCNAME=;UID=;PWD=;QUIETMODE=YES;') Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen(/Library/Application Support/teradata/client/ODBC/lib/tdata.dylib, 6): Library not loaded: libtdparse.dylib\n Referenced from: /Library/Application Support/teradata

Pyodbc query string quote escaping

梦想与她 提交于 2019-12-01 22:20:12
I'm trying to execute a query using pyodbc with this kind of code cursor.execute("SELECT x from y where Name='%s'"%namepar) The parameter may have a quote and so it needs to be escaped in order to work, how do i do thos? I tried by simply replacing " ' " with " \\' " in namepar and it still doesn't work, I get a pyodbc.ProgrammingError You can pass parameters, and that will be escaped. cursor.execute("SELECT x from y where Name = ?", (namepar,)) http://www.python.org/dev/peps/pep-0249/#id15 http://code.google.com/p/pyodbc/wiki/Cursor 来源: https://stackoverflow.com/questions/17139487/pyodbc

pyodbc calls sp_unprepare after sp_prepexec. Does that affect performance of parameterized queries?

故事扮演 提交于 2019-12-01 21:56:01
In continuation of SqlAlchemy+pymssql. Will raw parametrized queries use same execution plan? I switched from pymssql to pyodbc tried to get parametrized queries sent to SQL Server. pyodbc with Microsoft driver does the trick, but something seems strange to me: declare @p1 int set @p1=6 exec sp_prepexec @p1 output,N'@P1 nvarchar(6),@P2 bigint,@P3 bigint,@P4 bigint',N' SELECT * FROM CC_sold WHERE id_contract =@P1 AND id_tip_cont=@P2 AND CC_sold.anul =@P3 AND CC_sold.luna =@P4 ORDER BY CC_sold.anul, CC_sold.luna DESC ',N'176914',6,2016,9 select @p1 exec sp_unprepare 6 My worries are related to

pyodbc - error while running application within a container

倖福魔咒の 提交于 2019-12-01 21:48:39
I am having a python application that uses mssql - instead of using pymssql, i was trying pyodbc. There seems to be no problems while running the application in a Windows local machine. While deploying the application in a dev env packaged as a container, I see the following errors. from pyodbc import Error 2017-04-14T13:58:28.858638588Z ImportError: Error loading shared library libodbc.so.2: No such file or directory (needed by /usr/local/lib/python3.5/site-packages/pyodbc.cpython-35m-x86_64-linux-gnu.so) The docs require me to install the database drivers along with pyodbc. initial check

How to create permanent MS Access Query by Python 3.5.1?

非 Y 不嫁゛ 提交于 2019-12-01 21:42:10
I have about 40 MS Access Databases and have some troubles if need to create or transfer one of MS Access Query (like object) from one db to other dbs. So I tried to solve this problem with pyodbc but.. as I saw pyodbc doesn't support to create new, permanent MS Access Query (object). I can connect to db, create or delete tables/rows but can't to create and save new query. import pyodbc odbc_driver = r"{Microsoft Access Driver (*.mdb, *.accdb)}" db_test1 = r'''..\Test #1.accdb''' db_test2 = r'''..\Test #2.accdb''' db_test3 = r'''..\Test #3.accdb''' db_test4 = r'''..\Test #4.accdb''' db_test

Connecting to PostgreSQL using pyodbc

女生的网名这么多〃 提交于 2019-12-01 20:57:07
问题 I have a PostgreSQL running on localhost. I have psqlODBC Driver installed. Now when I try to connect to the server using pyodbc as: import pyodbc connection = pyodbc.connect("DRIVER={psqlOBDC};SERVER=localhost;DATABASE=weather;UID=postgres;PWD=password") but I get this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> pyodbc.Error: ('08001', '[08001] Already connected. (202) (SQLDriverConnect)') Whats the problem? Thanks. 回答1: Of course you must install ODBC

PyOdbc fails to connect to a sql server instance

两盒软妹~` 提交于 2019-12-01 20:44:54
I am trying to connect to a sql server instance using pyodbc version 3.0.6., SQLAlchemy 1.0.4 on Windows 7 using a Python 2.7 (32 bit). I am using a connection string as follows DRIVER={SQL Server};SERVER=mymachinename;DATABASE=mydb;UID=sa;PWD=admin1; but I keep getting this error Could not parse rfc1738 URL from string 'DRIVER={SQL Server};SERVER=mymachinename;DATABASE=mydb;UID=sa;PWD=admin1' I am using the connection string with sqlSoup.Something like this db = sqlsoup.SQLSoup(connectionstring) Edit I tried using Automap from SqlAlchemy and it also fails with the same message Traceback (most

Python with MS SQL - truncated output

十年热恋 提交于 2019-12-01 19:49:26
I try to connect to MSSQL DB with python from Linux box ( Python 2.7 , Ubuntu 11.04 ) . Output that I receive is truncated to 500 characters. Please, see script and configs below. How it could be resolved? The problem I suppose in ODBC driver or near it. The code (pyodbc, pymssql): conn = pymssql.connect(host='my_remote_host', user='ro_user', password='password', database='current', as_dict=True) cur = conn.cursor() cur.execute(sql) for i in cur: print i conn.close() cnxn = pyodbc.connect(driver='FreeTDS', server='my_remote_host', database='current', uid='ro_user', pwd='password') cursor =