pyodbc

Connecting to Microsoft SQL Server through pyODBC on Ubuntu

混江龙づ霸主 提交于 2019-12-23 07:47:31
问题 Am having an issue connecting to a Microsoft SQL Server instance from pyODBC within an Ubuntu (12.10) machine. The error I am getting back is: pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data Source name not found, and no default driver specified (0) (SQLDriverConnect)') The connection string am using for pyodbc is: self.corpus_cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=UKEDN-06880;DATABASE=db1;UID=user;PWD=pass') This seems to work fine from pyODBC within Windows (just

“Invalid parameter type” (numpy.int64) when inserting rows with executemany()

北城以北 提交于 2019-12-23 07:43:26
问题 I try to insert bunch of data to database insert_list = [(1,1,1,1,1,1),(2,2,2,2,2,2),(3,3,3,3,3,3),....] #up to 10000 tuples in this list conn = pyodbc.connect('DRIVER={FreeTDS};SERVER=xxxxx;DATABASE=xxxx;UID=xx;PWD=xx;TDS_Version=7.0') cursor = conn.cursor() sql = "insert into ScanEMAxEMAHistoryDay(SecurityNumber, EMA1, EMA2, CrossType, DayCross, IsLocalMinMax) values (?, ?, ?, ?, ?, ?)" cursor.executemany(sql, insert_list) cursor.executemany(sql, insert_list) pyodbc.ProgrammingError: (

How to build pyodbc with links to iODBC in macOS?

橙三吉。 提交于 2019-12-23 05:02:51
问题 In Driver for pyodbc: how to specify its location in macOS?, TallTed suggested to open question to explain the following Build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS). so now with the focus — How can I build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS)? 回答1: This should/might work in 4.0.23, as it was the way it was done up to pyodbc v3.0.7: First, in the file 'setup.py' change line 165 from: settings

apache2 mod_wsgi crashes when importing pyodbc

五迷三道 提交于 2019-12-23 04:01:46
问题 Operating system - Ubuntu Server 14.04 on Azure VM Tried with different versions of python (3.4.3, 3.6.0), apache and mod_wsgi. Installed MS Native ODBC driver using instructions from here https://gist.github.com/joecampo/6f777a659b8132b9d6fe1c3589df394c , while pyodbc was installed using pip. To debug the wsgi_module I have set up the django application to run in embedded mode and: gdb /usr/local/apache2/bin/httpd run -X When I access any function which imports pyodbc, the wsgi fails with

Set connection settings with Pyodbc + UnixODBC + FreeTDS

纵然是瞬间 提交于 2019-12-22 18:23:24
问题 I have a setup using Pyodbc, UnixODBC and FreeTDS, but somewhere in there some options are being set and I don't know where. According to SQL Server Management Studio, my program is sending some settings when it opens the connection: set quoted_identifier off set ansi_padding off set ansi_nulls off ... But I need a different set of settings: set quoted_identifier on set ansi_padding on set ansi_nulls on ... Is there any way to change this? If I can't do it with my current setup, are there any

Python pyodbc connect to ms access database

霸气de小男生 提交于 2019-12-22 17:06:24
问题 I am trying to connect my access database so I can dump my data into the table in the database. This the code I use: import pyodbc access_database_file = "C:\\Users\\Moyp\\DataPointe.accdb" ODBC_CONN_STR = 'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s;' %access_database_file conn = pyodbc.connect(ODBC_CONN_STR) However, I keep receiving this error: Traceback (most recent call last): File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code exec

Cannot connect to Azure SQL using an alpine docker image with Python

浪子不回头ぞ 提交于 2019-12-22 12:54:20
问题 I have an alpine based docker image, with support for Python, through which I am trying to connect to Azure SQL service. Here is my simple connection code. I am getting an error when connecting to SQL server in Azure. conn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password) pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")nect)")

PyODBC return error, but why?

瘦欲@ 提交于 2019-12-22 10:34:37
问题 I try execute T-SQL query in two cases (i use Win7, python 3.2, MS SQL Server express 2008,pyodbc for python 3.2): -case 1: using MS SQL Server Management Studio i try to execute query: USE master;CREATE DATABASE Sales ON (NAME = Sales_dat,FILENAME = 'C:\saledat.mdf', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5 ) LOG ON ( NAME = Sales_log, FILENAME = 'C:\salelog.ldf', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB ); it return successful result -case 2: import pyodbc cxnn=pyodbc.connect('DSN=SERVER

The first argument to execute must be a string or unicode query

你说的曾经没有我的故事 提交于 2019-12-22 08:46:38
问题 I am trying to upload a blob data to ms-sql db, using pyodbc. And I get "the first argument to execute must be a string or unicode query" error. The code is file = pyodbc.Binary(open("some_pdf_file.pdf", "r").read()) cur.execute("INSERT INTO BlobDataForPDF(ObjectID, FileData, Extension) VALUES ('1', " + file + ", '.PDF')") cur.commit() The first argument, ObjectID, is sent as a string. I don't see any problem but am I missing something? 回答1: Use parameterized insert: file = pyodbc.Binary(open

How to use Django with Sql Server

只愿长相守 提交于 2019-12-22 06:36:29
问题 I normally use Postgres for my database needs with Django but I recently started at a company which use MSSQL on a Windows environment. Long story short I had to rewrite the database properties in settings.py. Unfortunately, I have NO idea how to connect to a SQL Server using Pyodbc and they're running Python 3.x so I can't use Django-Pyodbc. While trying to run it I'm getting a: "Data source name not found and no default driver specified (0) (SQLDriverConnect)')" Here is my current db config