pyodbc

Binding a null value to a date field in pyodbc

Using pyodbc, if I try and execute this code on a date field: cursor.execute('insert into test VALUES (?)', None) ... I get pyodbc.Error: ('HY000', '[HY000] [SAS][SAS ODBC Driver][SAS Server]ERROR: Value 1 of VALUES clause 1 does not match the data type of the corresponding column in (-1) (SQLExecDirectW)'), while if I execute this: ...

Unable to install pyodbc on Linux

Hi, I am running Linux (2.6.18-164.15.1.el5.centos.plus) and trying to install pyodbc. I am doing pip install pyodbc and get a very long list of errors, which end in error: command 'gcc' failed with exit status 1 I looked in /root/.pip/pip.log and saw the following: InstallationError: Command /usr/local/bin/python -c "import...

Using SQL Alchemy and pyodbc with IronPython 2.6.1

I'm using IronPython and the clr module to retrieve SQL Server information via SMO. I'd like to retrieve/store this data in a SQL Server database using SQL Alchemy, but am having some trouble loading the pyodbc module. Here's the setup: IronPython 2.6.1 (installed at D:\Program Files\IronPython) CPython 2.6.5 (installed at D:\Python26...

sqlalchemy date type in 0.6 migration using mssql

I'm connection to mssql server through pyodbc, via FreeTDS odbc driver, on linux ubuntu 10.04. Sqlalchemy 0.5 uses DATETIME for sqlalchemy.Date() fields. Now Sqlalchemy 0.6 uses DATE, but sql server 2000 doesn't have a DATE type. How can I make DATETIME be the default for sqlalchemy.Date() on sqlalchemy 0.6 mssql+pyodbc dialect? I'd l...

pyODBC and Unicode Problem

Hey guys, I'm working with pyODBC communicate with a MS SQL 2005 Express server. The table to which i'm trying to save the data consists of nvarchar columns. query = u"INSERT INTO tblPersons (name, birthday, gender) VALUES('" query = query + name + u"', '" query = query + birthday + u"', '" query = query + gender + u"')" cur.exe...

sql server function native parameter bind error

I'm using the following software stack on Ubuntu 10.04 Lucid LTS to connect to a database: python 2.6.5 (ubuntu package) pyodbc git trunk commit eb545758079a743b2e809e2e219c8848bc6256b2 unixodbc 2.2.11 (ubuntu package) freetds 0.82 (ubuntu package) Windows with Microsoft SQL Server 2000 (8.0) I get this error when trying to do nativ...

Manipulating the db with SQL Server 2005 - Django

Hi folks, I'm trying to accomplish the following: Grab the db schema Grab any constraints* Alter tables Add/Drop tables I'm currently using pyodbc backend for Django. I would like to perform all these tasks within a view file. I'm using the following in order to grab fields of tables starting with 'core_': SELECT table_name,or...

import pyodbc results in DLL load failed with error code 193 on Win7

I am running 64-bit Windows 7 and the ActiveState Python 2.5 installation (64-bit version). I just downloaded and installed the pyodbc 2.1.7 win32 package. When I run the installer as an admin it proceeds with no problem. When I run python and try import pyodbc I receive the following error: ImportError: DLL load failed with ...

How to connect pyodbc to an Access (.mdb) Database file

Here's what I've tried: -Find Vista's ODBC Data Source Manager* through search, -Add a new File Data Source*, selecting Driver for Microsoft Access (*.mdb), and selecting my mdb file of interest, -import pyodbc from python shell and try: pyodbc.connect("DSN=<that Data Source I just created>") I get the following error message (Port...

FreeTDS translating MS SQL money type to python float, not Decimal

I am connecting to an MS SQL Server db from Python in Linux. I am connecting via pyodbc using the FreeTDS driver. When I return a money field from MSSQL it comes through as a float, rather than a Python Decimal. The problem is with FreeTDS. If I run the exact same Python code from Windows (where I do not need to use FreeTDS), pyodbc ...

Set connection settings with Pyodbc + UnixODBC + FreeTDS

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 se...

How to strip "()," from Python, PyODBC, SQL Returns?

Hi, I grabbed a bunch of SQL IDs I need to update with Python and PyODBC: import pyodbc cnxn = pyodbc.connect('DSN=YesOne;PWD=xxx') cursor = cnxn.cursor() cursor.execute("SELECT ID FROM One.dbo.Two WHERE STATUS = 'OnGoing' AND ID = ''") I have a second bit of code that updates the IDs: cursor.execute("Update One.dbo.Two SET STATUS =...

Wrapper on conneting Sybase ASE using pyodbc in Django?

I wonder any one is conneting Sybase ASE using pyodbc in Django? Any wrapper available for that? Any solution? Currently there are: - sqlany-django (http://code.google.com/p/sqlany-django/) for Sybase SQL Anywhere and not Sybase ASE - django-pyodbc (http://code.google.com/p/django-pyodbc/) for MS SQL Server through pyodbc Thanks. ...

Wrong types while executing UPDATE in Oracle db via pyodbc

I'm using pyODBS to connect to Oracle database. Connection and executing SELECT query works fine. The only problem is error on UPDATE query executing. I have table: CREATE TABLE stud (num NUMBER(6) NOT NULL, fname NVARCHAR2(70), year NUMBER(4), bday DATE, plata NUMBER(1) DEFAULT 0 CHECK(plata IN (0,1)), mb NUMBER...

Using Microsoft Access SQL operators in Python ODBC

Short version: When I try to use Access's DatePart function via ODBC, it cannot be resolved. Longer version: I have a Microsoft Access query which returns rows with a timestamp and a score. I want to sort it by day and then by score - effectively a high-score table for the day. For want of a better function, I used the DatePart funct...

pyodbc and mySQL

I am unable to connect to mySQl db using pyodbc. Here is a snippet of my script: import pyodbc import csv cnxn = pyodbc.connect("DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=mydb; UID=root; PASSWORD=thatwouldbetelling;") crsr = cnxn.cursor() with open('C:\\skunkworks\\archive\\data\\myfile.csv','r') as myfile: rows...