Is there a way to use a pyodbc connection without a dialect?  I'd prefer to 
not have to create a custom dialect to talk to my Teradata server as I have 
gotten pyodbc to work well.  Seems like since ODBC is a standard that I 
might be able to get enough functionality out of it.  Is this even 
 possible?

I've been trying something like

import pyodbc
from sqlalchemy import create_engine

def getconn()
    pyodbc.pooling = False  # required or Teradata ODBC dumps
    return pyodbc.connect('DSN=tdprod')

engine = create_engine('pyodbc://tdprod', creator=getconn)


Barring that working which seems unlikely since I can't find any working 
examples, I have started stubbing out a very simple Teradata dialect but I 
can't figure out how to manually set pyodbc.pooling = False.  This is 
required as the TD ODBC driver will core dump on connect if this isn't set. 
 I've tried the following in the my pyodbc.py my dialect but on testing it 
core dumps indicating the value isn't being set.

Here is the pyodbc.py for my TD dialect.  I'm trying to control pooling in 
two different ways in this example but neither works:

import pyodbc

from .base import TeradataDialect, TeradataExecutionContext
from sqlalchemy.connectors.pyodbc import PyODBCConnector

pyodbc.pooling = False

class TeradataExecutionContext_pyodbc(TeradataExecutionContext):
    pass

class TeradataDialect_pyodbc(PyODBCConnector, TeradataDialect):
    execution_ctx_cls = TeradataExecutionContext_pyodbc

    pyodbc_driver_name = 'Teradata'

    def initialize(self, connection):

        # Teradata requires pooling off for pyodbc
        super(TeradataDialect_pyodbc, self).initialize(connection)
        self.dbapi.pooling = False

dialect = TeradataDialect_pyodbc

Here is the output of the test:

metl@ichabod:~/src/etl/util/sqlalchemy/dialects/teradata$ python 
run_tests.py
nose.plugins.cover: ERROR: Coverage not available: unable to import 
coverage module
Fatal Python error: Unable to set SQL_ATTR_CONNECTION_POOLING attribute.
Aborted (core dumped)

The Fatal Python error is the same error I get if I attempt to connect to 
my Teradata database via pyodbc without first setting pooling = False.  Any 
help would be appreciated.

Mike


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to