Skip to content

Instantly share code, notes, and snippets.

View dmpeters's full-sized avatar
👨‍🔧

David Peters dmpeters

👨‍🔧
View GitHub Profile
@dmpeters
dmpeters / foo.md
Last active August 29, 2015 14:21

The Perils of CouchDB / Postgres to the rescue

CouchDB as an application database kind of sucks. Basically the only reason to use it is because it easily supports unstructured data. Even so, its limitations have a ton of negative ripple effects on basically the entire development process.

Luckily, Postgres has an hstore column type and has recently added a json column type. json supports arbitrary JSON but is stored as text so operations are slower. hstore stores only a flat mapping of string keys and values in a fast binary format, but nesting is on tap for 9.4 (Q3 2014) and non-string types are on the roadmap. In the meantime, nesting can be simulated by storing the full path to a value as the string key, and types can be handled in the application layer including with a query building abstraction that automatically casts hstore values to their expected types in database queries.

Postgres supports a number of other features that all together make it look like a great solution for scalably storing m

@dmpeters
dmpeters / backend.py
Last active August 29, 2015 14:22 — forked from dmitric/backend.py
class Backend(object):
def __init__(self):
engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db)
, pool_size = options.mysql_poolsize
, pool_recycle = 3600
, echo=options.debug
, echo_pool=options.debug)
self._session = sessionmaker(bind=engine)
@classmethod

Keybase proof

I hereby claim:

  • I am dmpeters on github.
  • I am doxdpeters (https://keybase.io/doxdpeters) on keybase.
  • I have a public key ASCoOsiomE0jJQloGlC0o1hANU9bOq78zsqGvsS53xkReAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am dmpeters on github.
  • I am dmpeters63 (https://keybase.io/dmpeters63) on keybase.
  • I have a public key ASAnsztVeuUCPoBehuG5qth7wvALLo79Gp5S8zgZI9Y7kQo

To claim this, I am signing this object: