Error accessing external Redshift with psycopg2

Hi,

I’m trying to access an AWS Redshift instance using the psycopg2 library per the External Database example but getting an error: ModuleNotFoundError: No module named ‘psycopg2’

I did find some other posts referencing a similar problem but different message so I assume this library requires an upgrade to a paid account in order to use the Full Python 3, correct?

Also, our AWS account has additional security requiring an SSH tunnel (Bastion). Do you have sshtunnel library available with Full Python 3 and do you know if any Anvil users have had the similar security requirements/implementation and used these libraries successfully?

I was hoping to test this out before upgrading–any other solution possible with the free account?

Thanks.

Python3 will implement a wide variety of packages in the browser. The exceptions would mostly be ones that rely on compiled C++ under the hood but you can use these with a server module or uplink.

Good news here is that a paid Anvil subscription is way cheaper than Redshift.

As @navigate mentioned, you can use Anvil Uplink to accomplish this without needing sshtunnel – I’d definitely recommend that. It allows you to run server code on external machines, including your own EC2 instances that have direct access to Redshift. I use Uplink extensively for this purpose.

He’s also right that a paid Anvil subscription is worth every penny. :slight_smile:

2 Likes

Thanks for the response!
Do I understand you to mean that in this particular case those two libraries are available in the Individual subscription?

Thanks for the response.

In this case, I don’t have access to the EC2 instance so would like to just be able to tunnel from Anvil if that would work with those libs if available in the paid subscription–is that possible?

Got it. You can find a list of available packages here: https://anvil.works/docs/server/packages I don’t see sshtunnel on the already-installed list, so I think you’ll need to send a note to support to see about having it added. Your use case definitely makes sense since you can’t access the data any other way.

One other thought for your proof-of-concept - if you can install sshtunnel on your own machine, you could still use Uplink by just running it locally. The Uplink doesn’t necessarily need to be running inside the secure environment, it just needs to be able to access the data (via bastion server would be fine).

P.S. I hope I’m not coming on too strong with another Uplink suggestion - I’ve just spent my fair share of time in corporate environments where data’s locked down and recurring expenses are hard to push through before an idea is proven out. So I figured no harm in suggesting a creative workaround. Good luck!

Yes, we can get sshtunnel installed for you in the Full Python environments on the paid account. Drop us a line at support@anvil.works!

2 Likes