Does Pipedream support psycopg2 and are other users facing similar issues?

This topic was automatically generated from Slack. You can find the original thread here.

I’m back to trying to use psycopg2 in a python block of code. I tried the magic comment system:

# pipedream add-package psycopg2

import psycopg2

I’m still getting error from PIP. So I’m curious:

  1. Are other users seeing this same behavior?
  2. Can Pipedream confirm that they do or do not support psycopg2 ?

Hi , as I checked, the psycopg2 library is used for interacting with Postgres. It is implemented mostly in C to support multithread environment, which might not be compatible with Pipedream.

Could you try to use Pipedream builtin Postgres actions?

I understand what you are requesting and in a few workflows I have been. I’ll have to think through my current workflow. It is python that has gathered a CSV and needs to iterate every row (500+) and check or update values in the db. So doing this within Python code is preferred.

I’ve started looking at what other postgres python libraries there are to see if one of those will work.

It seems I’m able to get asyncpg to work, at least in synchronous mode, probably not in asynchronous mode.

I was getting some errors withpg8000 and py-postgresql . pg8000 may have been some issue with SSL and py-postgresql looks like some error with something under the hood in Pipedream as the error was pointing out invalid syntax (__init__.py, line 3)

I’ll press on with asyncpg and see how it fairs.

grrr…trying to either make asyncpg operate synchronously or to make the Pipedream python code work async and I’m over my head on either. ChatGPT (my coding buddy!) is trying too, just not getting the right thing.

Interesting note. If I change **def** handler(pd: "pipedream"): to async **def** handler(pd: "pipedream"): and test the code block, it quickly returns Success, but it clearly didn’t run anything. I wonder if there should be an error or message about not find or running handler(pd).

When I add asyncio.run(handler(pd)) to the bottom of my python code, I get error Script returned exit code 1