-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replication support #71
Comments
Hi, If this still an issue, I could take a look and use your guidance to implement this. |
If you would like to contribute to it you are welcome. |
@dvarrazzo What sort of support exists today to get logical replication working in an async mode? I guess logical replication subscription as supported by psycopg2.extras - ReplicationCursor is not currently in psycopg3. Can I still somehow use the SQL queries directly like (CREATE SLOT, START REPLICATION) to get changes as they happen? asyncpg mentions this snippet of code in one of their issues regarding replication: MagicStack/asyncpg#91 async def poll_replication_stream(conn):
while True:
async for r in conn.fetch('SELECT * FROM pg_logical_slot_get_changes(...)'):
await put_to_queue(r)
await asyncio.sleep(polling_interval)
...
conn = await asyncpg.connect(...)
loop.create_task(poll_replication_stream(conn)) I'm assuming something like this will work with psycopg3 as well? |
@dvarrazzo Could you please also explain exactly what would need to be added to support replication directly in psycopg3? I'm taking a look at the code right now & having some pointers on exactly what needs to be done would be great! |
Replication support is not implemented in psycopg 3. It needs complete redesign and implementation. If you want to contribute its implementation you are welcome, but it is a major work. |
Yeah, I realised that after looking at the code of pg2 & pg3. I guess it'll require a lot of interfacing with pq as well? My current plan is to use something like Or perhaps I won't do this in async mode and just use pg2 directly. I found pypgoutput which does client side decoding of pgoutput format to JSON: https://github.com/dgea005/pypgoutput |
Add support for streaming replication as in psycopg2
The text was updated successfully, but these errors were encountered: