Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
/ pg_channels Public archive

Python wrapper for PostgreSQL NOTIFY and LISTEN commands.

License

Notifications You must be signed in to change notification settings

nickdmoore/pg_channels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PG Channels

Python wrapper for PostgreSQL NOTIFY and LISTEN commands.

Installation

pip install pg_channels

Usage

First, establish a connection to the PostgreSQL database:

import pg_channels

pgc = pg_channels.connect(host='localhost', database='mydb')

Sending notification events:

pgc.notify('channel_one', 'Some data')

Subscribing to a channel and and handling notification events:

# Subscribe (listen) to a specific channel
pgc.listen('channel_two')

# Iterate over any notification events
for event in pgc.events():
	some_func(event.payload)