Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Created March 5, 2014 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phillipsj/9367366 to your computer and use it in GitHub Desktop.
Save phillipsj/9367366 to your computer and use it in GitHub Desktop.
Repository pattern example for Postgres-py
from postgres.orm import Model
from postgres import Postgres
class Foo(Model):
typname = "foo"
class FooRepository(connection_string):
def __init__(self):
self.db = Postgres(connection_string)
self.db.register_model(Foo)
def get_all(self):
return self.db.all("SELECT foo.*::foo FROM foo")
repo = FooRepository("<connection-string>")
foos = repo.get_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment