lurcher / unixODBC

The unixODBC Project goals are to develop and promote unixODBC to be the definitive standard for ODBC on non MS Windows platforms.
GNU Lesser General Public License v2.1
94 stars 51 forks source link

Example configuration for Text File Driver #155

Closed cdwilson closed 6 months ago

cdwilson commented 6 months ago

Are there any examples or documentation for how to configure the Text File Driver backed by a CSV file?

In my specific case, I'd like to use the Text File Driver on macOS (ARM) Sonoma to allow an application to read data from a CSV file via ODBC. I've installed unixODBC via homebrew (with --enable-drivers & --enable-driver-config enabled), but, I'm not sure exactly what to specify in odbcinst.ini & odbc.ini to get this working.

For more context, I have an existing configuration working with a SQLite DB (see here for details), but I'd like to replace this SQLite3 driver with the unixODBC Text File Driver backed by a CSV file:

[ODBC Drivers]
SQLite3 = Installed

[SQLite3]
Driver = /opt/homebrew/lib/libsqlite3odbc.dylib
Setup  = /opt/homebrew/lib/libsqlite3odbc.dylib

When I search for odbctxt after installing, the only thing I see is /opt/homebrew/lib/libodbctxtS.so, which I'm guessing might be the setup lib I should use here (but wasn't sure because it didn't have the .dylib extension like the SQLite driver).

What should I specify for Driver and Setup? And how do I specify the properties to configure the Text File Driver?

Any help or guidance on getting this set up would be greatly appreciated! (and apologies if this isn't the correct place to ask questions like this)

lurcher commented 6 months ago

On 13/01/2024 21:45, Chris Wilson wrote:

Are there any examples or documentation for how to configure the Text File Driver backed by a CSV file?

In my specific case, I'd like to use the Text File Driver on macOS (ARM) Sonoma to allow an application to read data from a CSV file via ODBC. I've installed unixODBC via homebrew (with |--enable-drivers| & |--enable-driver-config| enabled), but, I'm not sure exactly what to specify in |odbcinst.ini| & |odbc.ini| to get this working.

For more context, I have an existing configuration working with a SQLite DB (see here https://cdwilson.dev/articles/kicad-database-libraries-on-macos/ for details), but I'd like to replace this SQLite3 driver with the unixODBC Text File Driver backed by a CSV file:

|[ODBC Drivers] SQLite3 = Installed [SQLite3] Driver = /opt/homebrew/lib/libsqlite3odbc.dylib Setup = /opt/homebrew/lib/libsqlite3odbc.dylib |

When I search for |odbctxt| after installing, the only thing I see is |/opt/homebrew/lib/libodbctxtS.so|, which I'm guessing might be the setup lib I should use here (but wasn't sure because it didn't have the |.dylib| extension like the SQLite driver).

What should I specify for |Driver| and |Setup|? And how do I specify the properties to configure the Text File Driver?

Any help or guidance on getting this set up would be greatly appreciated! (and apologies if this isn't the correct place to ask questions like this)

The text file driver is very very simplistic and lacking just about everything to make its of use, its just a sample of driver code.

cdwilson commented 6 months ago

Thanks for the clarification, I'll close this out.

If you happen to know of an open-source ODBC driver that can read directly from a CSV file (or other flat file like JSON, YAML, etc), I'd be interested to know about it.