On Jun 21, 2011, at 10:25 AM, David Marsh wrote:
> I'm trying to get SQAlchemy to connect to a collection of DBFs and I'm
> having some difficulty.
>
> If I use pyodbc, I can connect and extract data using the following
> connection string:
>
> 'Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:\\path\\to\
> \dbfs;'
>
> I'm having trouble translating this into something that sqlalchemy can
> use. All of the posts/docs I've seen seem to be connecting to another
> server, not reading DBFs out of a folder.
>
> Is there a way to do this in SQLAlchemy? Am I on the right track
> using pyodbc? Does SQLAlchemy have another method of connecting to
> DBFs that I haven't discovered yet?
SQLAlchemy doesn't have a dialect for DBF files, so while you could make an
engine that connects to such a connection, its not clear what SQLAlchemy would
do with this database once connected - it would need to act very, very
similarly to Microsoft SQL Server or at least Access. The Access dialect
hasn't been upgraded since 0.5 however, so we might not have a working solution
here without someone willing to work on a dialect.
It's probably possible to build a "generic" pyodbc dialect for use cases like
these (assuming you want to do just SELECTs), but there's still some critical
areas, namely primary key generation, that would probably have to remain
undefined for such a dialect, so it would only have a limited, mostly read-only
set of functionality.
An entirely different way to do this is to convert your DBF file to SQLite -
once in SQLite you'd be master of the universe. Here's a thread i found which
has some various ways of doing it (unfortunately doesn't seem like there's a
comprehensive tool yet):
http://www.velocityreviews.com/forums/t691275-convert-dbase-dbf-files-to-sqlite-databases.html
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.