How hard is it to write a new dialect?
Anyone had luck using generic odbc (ie not mysql moduled to pyodbc) to
connect to various "unsupported" databases?
I've tried a couple connection strings, the biggest problem is 4D
doesn't have a "database" name.
# connect to the actual database
from sqlalchemy import create_engine
#using DSN
engine = create_engine('mysql+pyodbc://4D_v11_Dev/DEFAULT_SCHEMA')
#using URL
engine = create_engine('mysql://user:pa...@127.0.0.1', module='pyodbc')
#another dialect with DSN => ERROR: AttributeError: 'str' object has
no attribute 'paramstyle'
engine = create_engine('mssql://4D_v11_Dev', module='pyodbc')
# yet another try
engine = create_engine('mysql+pyodbc://4D_v11_Dev')
# show me output
engine.echo = True
None of those work, I have some stack traces, but the gist is this:
# when used without a database name
sqlalchemy.exc.DBAPIError: (Error) ('08004', '[08004] Server rejected
the connection:\nFailed to parse statement.\r (1301)
(SQLExecDirectW)') 'SELECT DATABASE()' ()
# when I try to specify a name
sqlalchemy.exc.DBAPIError: (Error) ('00000', '[00000] [iODBC][Driver
Manager]dlopen({MySQL}, 6): image not found (0) (SQLDriverConnectW)')
None None
But connection directly via pyodbc does work
import pyodbc
cnxn = pyodbc.connect("DSN=4D_v11_Dev;UID=user;PWD=pass")
cursor = cnxn.cursor()
cursor.execute('select * from ODBCTest')
a=cursor.fetchall()
print 'pyodbc',a
> Anyone heard of 4D? Probably not, but I would love to work with
> SQLAlchemy and this database.
>
> How hard is it to write a new dialect?
by all reports, including some new ones gained today at pycon, it is extremely easy. provided your database is relational.
>
> Anyone had luck using generic odbc (ie not mysql moduled to pyodbc) to
> connect to various "unsupported" databases?
step 1, get pyodbc to connect to your database. that may be easy or may involve contacting the pyodbc author for fixes.
step 2, create a .py file that imports the PyODBC connector as a mixin to "class YourDialect()", the same way as any other dialect, and make any changes to the "create_connect_args" method as necessary in your subclass.
step 3, establish a setup.py for your application which establishes your library as a setuptools entrypoint for "sqlalchemy.dialects". the name you give it is what you'd call upon in create_engine(). I'd suggest a name like "4d+pyodbc".
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>