lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

Unable to use custom drivers with pyodbc

Open MetricMike opened this issue 7 years ago • 1 comments

the libodbc.so.2 from #73 appears to be using unixODBC's defaults which means odbcinst -j produces

DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini

but since /etc/ isn't modifiable in Lambda, we're stuck with the default MySQL and PostgreSQL drivers. If I wanted to add another driver, I'm out of luck.

After recompiling unixODBC with ./configure --prefix=/var/task/unixODBC, I was able to:

vi /var/task/unixODBC/etc/odbc.ini
vi /var/task/unixODBC/etc/odbcinst.ini
ln -s /var/task/unixODBC/lib/libodbc.so.2.0.0 /var/task/libodbc.so.2

and everything seems to be in order.

I'm a little confused how this package ever worked though, given that with the default configuration:

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver    = /usr/lib/psqlodbc.so
Setup   = /usr/lib/libodbcpsqlS.so
Driver64  = /usr/lib64/psqlodbc.so
Setup64   = /usr/lib64/libodbcpsqlS.so
FileUsage = 1

# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL
Driver    = /usr/lib/libmyodbc5.so
Setup   = /usr/lib/libodbcmyS.so
Driver64  = /usr/lib64/libmyodbc5.so
Setup64   = /usr/lib64/libodbcmyS.so
FileUsage = 1

none of these files exist in Lambda and neither /usr/lib/ /usr/lib64/ are writable.

@FlipperPA, can you provide any insight here? I'd like to pinpoint what's going on before I submit a PR addressing the issue.

MetricMike avatar Jun 18 '18 19:06 MetricMike

Howdy @MetricMike - I like your solution a lot more than what I was doing. I only did this as a proof on concept for another user, and relied on having an .odbcinst.ini in the Lambda's home directory. I was going to come up with a better solution, but the person asking for this proof on concept stopped responding, so I stopped working on it! As for odbc.ini, IIRC, I only used FQDN's to connect, not DSNs. I hope this helps!

FlipperPA avatar Jun 18 '18 22:06 FlipperPA

Thanks! Going to clarify today our contribution policy, then will try to get this in.

matthewp avatar Apr 13 '21 13:04 matthewp

Sounds good, thanks! I know the drill; there’s a contribution agreement for w3c repos.

If I need to agree to any specific terms, let me know. 👍

jonathantneal avatar Apr 13 '21 13:04 jonathantneal

All is good, thanks for this!

matthewp avatar Apr 13 '21 17:04 matthewp