Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A PostgreSQL Environment for Activipy

Project Description

An activipy environment to use PostgreSQL as the data store for ActivityStream objects.

The activipy module enables the use of ActivityStreams in your applications and includes the support of different “environments” to extend functionality.

This package provides a “pgsql” environment that maps storage methods to PostgreSQL queries using psycopg2. Object data is stored using the jsonb data type to simplify the schema and provide maximum performance.

Example Code

Open a database:

>>> from activipy import core, vocab
>>> from activipy.pgsql import pgsql
>>> db =
... host="<db_server>", dbname="<db_name>",
... user="<db_user>", password="<db_user_pass>")
>>> env = pgsql.PgSQLNormalizedEnv

Create a new record and save to database:

>>> post_this = core.ASObj({
...     "@type": "Create",
...     "@id": "",
...     "actor": {
...         "@type": "Person",
...         "@id": "",
...         "displayName": "Jessica Tallon"},
...     "to": ["",
...            "",
...            "acct:ladyaeva@hedgehog.example"],
...     "object": {
...         "@type": "Note",
...         "@id": "",
...         "content": "Up for some root beer floats?"}},
... pgsql.PgSQLNormalizedEnv)
{'@type': 'Create',
 '@id': '',
 'actor': '',
 'to': ['',
 'object': ''}

Note how in this example the record has been normalized. In this environment the actor and object are created in separate records and made into references in the parent record. To retrieve the original denormalized form:

>>> normalized_post = pgsql.pgsql_fetch(
... "", db, env)
>>> normalized_post.m.denormalize(db)
<ASObj Create "">
>>> normalized_post.m.denormalize(db).json()
{'to': ['',
 '@id': '',
 '@type': 'Create',
 'actor': {'@id': '',
           '@type': 'Person',
           'displayName': 'Jessica Tallon'},
 'object': {'@id':
            '@type': 'Note',
            'content': 'Up for some root beer floats?}}

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(7.9 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Dec 15, 2017
(22.4 kB) Copy SHA256 Hash SHA256
Source None Dec 15, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers