-2

Can you please assist me adding the python pyodbc layer for 3.11 python runtime version? Earlier, i had the pyodbc layer for 3.7 which i exported from https://github.com/kuharan/Lambda-Layers?source=post_page-----e7667d371cc5-------------------------------- Now, 3.7 runtime is about to deprecate , i need to switch it to 3.11 latest version.

.I have tried many ways to add but got multiple errors. i) I used updated pyodbc .whl file and made zip out of it and uploded to aws-layer. but says 'lambda_function': No module named 'pyodbc'

ii) Unable to import module 'app': libodbc.so.2: cannot open shared object file: No such file or directory

Something like this.

0

2 Answers 2

2

I just figured this out today. For a pyodbc lambda layer that works with the newest Python runtime 3.11, you must place your config files inside of the python folder when creating the zip. Here is a link to my github where I put the .zip file for the pyodbc python 3.11 layer. It has the MSSQL ODBC 17 driver. I could not get it to work with 18 because the sql server I was trying to query was version 12, which I don't think accepts anything newer than 17.

https://github.com/andersonguse/lambda-layers/blob/master/pyodbc311.zip

Please let me know if you have any questions.

Sign up to request clarification or add additional context in comments.

4 Comments

Any idea where I can get a pyodbc layer for python3.10?
@anderson-guse I am trying your layer with my Lambda running 3.11 But I am getting this error: [Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect) I am assuming you did not run into that? I have it working locally with the ODBC Driver 17, just not when it is deployed.
@SamuelChalvet what's your connection statement? Mine is below. conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + os.environ['server'] + ';DATABASE=' + os.environ['database'] + ';UID=' + os.environ['username'] + ';PWD=' + os.environ['password'])
@anderson-guse Yes, mine looks the same. I had Port as well, but I tried exactly what you pasted and got the same results. :(
1

To make that work, you need certain files alongside the PyODBC library, as @anderson-guse mentioned. For now, you can use the pre-built artifacts I've created, which are ready to use for Python 3.9 to 3.12. You can find them on my GitHub here.

Note: These artifacts currently support only the x86_64 architecture.

2 Comments

I found myself deep in this rabbit hole and spent hours building and debugging lambda layer for this without success. But this solution worked like a charm!
hi Vicky, does your solution also support SQL server aswell as MYSQL?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.