Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

jo-m/pgjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PgJSON

A highly experimental, extremely hacky but working attempt to mis-use PostgreSQL as a document oriented database.

Much is inspired and stolen from CouchDB-Python, especially the Mappings.

from pgjson.mapping import PgDocument, Mapping, ListField, \
    TextField, BooleanField, DictField
from pgjson.client import PgDatabase


class User(PgDocument):
    _version = 1

    profile = DictField(Mapping.build(
        profile_text=TextField(),
        language=TextField(),
        profile_image_url=TextField(),
        timezone=TextField(),
        phone=TextField(),
        location=TextField(),
        urls=ListField(DictField(Mapping.build(
            url=TextField(),
            description=TextField(),
            label=TextField(),
        ))),
        callname=TextField(),
        biz_address=TextField(),
        fullname=TextField(),
    ))
    locked = BooleanField(default=False)
    email = TextField()

db = PgDatabase("postgres://localhost/test")
db.setup_tables()

user = User(email='john@example.org')
user.profile.callname = u'John Doe'
user.store(db)
print user.id

About

Very experimental and hacky, but working attempt to abuse PostgreSQL as a document database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages