Skip to main content

JSON Object storage backed by Git & Elastic Search

Project description

Adventures in an declarative object-y thing backed by Git and using Elastic Search as a query backend.

https://travis-ci.org/smn/elastic-git.svg?branch=develop https://coveralls.io/repos/smn/elastic-git/badge.png?branch=develop

Usage

from elasticgit.manager import EG
from elasticgit.models import Model, IntegerField, TextField


workspace = EG.workspace('/Users/sdehaan/Desktop/test-repo/')
workspace.setup('Simon de Haan', 'simon@praekeltfoundation.org')


"""
# The model looks like this

class Person(Model):
    age = IntegerField('The Age')
    name = TextField('The Name')
"""
from elasticgit.tests.base import TestPerson as Person

person1 = Person({'age': 10, 'name': 'Foo'})
workspace.save(person1, 'Saving Person 1')

person2 = Person({'age': 20, 'name': 'Bar'})
workspace.save(person2, 'Saving Person 2')

person3 = Person({'age': 30, 'name': 'Baz'})
workspace.save(person3, 'Saving Person 3')

Data is now persisted in a git repository and is queryable via elastic search:

>>> from elasticgit.manager import EG
>>> from elasticgit.tests.base import TestPerson as Person
>>> workspace = EG.workspace('/Users/sdehaan/Desktop/test-repo/')
>>> for person in workspace.S(Person).filter(age__gte=20):
...     print person.get_object(), dict(person.get_object())
...
<elasticgit.tests.base.TestPerson object at 0x10f906d90> {'age': 20, 'uuid': u'9890c5813fc14fcd82a3ec3751a1b1fe', 'name': u'Bar'}
<elasticgit.tests.base.TestPerson object at 0x10f906d90> {'age': 30, 'uuid': u'4b5c33de63034205ac23b746ee93344b', 'name': u'Baz'}
>>> for person in workspace.S(Person).query(name__match='Baz'):
...     print person.get_object(), dict(person.get_object())
...
<elasticgit.tests.base.TestPerson object at 0x10f906d90> {'age': 30, 'uuid': u'4b5c33de63034205ac23b746ee93344b', 'name': u'Baz'}
>>>

Git log output of the repository

commit 89afa833e4c537293a5f21d4e867cd061ece82a9
Author: Simon de Haan <simon@praekeltfoundation.org>
Date:   Tue Oct 7 15:23:30 2014 +0200

    Saving Person 3

diff --git a/elasticgit.tests.base/TestPerson/4b5c33de63034205ac23b746ee93344b.json b/elasticgit.tests.base/TestPerson/4b5c33de63034205ac23b746ee93344b.json
new file mode 100644
index 0000000..03d55b8
--- /dev/null
+++ b/elasticgit.tests.base/TestPerson/4b5c33de63034205ac23b746ee93344b.json
@@ -0,0 +1,5 @@
+{
+  "age": 30,
+  "uuid": "4b5c33de63034205ac23b746ee93344b",
+  "name": "Baz"
+}
\ No newline at end of file

commit bc3b779ade98dacfdcb181dd6a24bc4c9350bdd3
Author: Simon de Haan <simon@praekeltfoundation.org>
Date:   Tue Oct 7 15:23:28 2014 +0200

    Saving Person 2

diff --git a/elasticgit.tests.base/TestPerson/9890c5813fc14fcd82a3ec3751a1b1fe.json b/elasticgit.tests.base/TestPerson/9890c5813fc14fcd82a3ec3751a1b1fe.json
new file mode 100644
index 0000000..3fb0070
--- /dev/null
+++ b/elasticgit.tests.base/TestPerson/9890c5813fc14fcd82a3ec3751a1b1fe.json
@@ -0,0 +1,5 @@
+{
+  "age": 20,
+  "uuid": "9890c5813fc14fcd82a3ec3751a1b1fe",
+  "name": "Bar"
+}
\ No newline at end of file

Project details


Download files

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

Source Distribution

elastic-git-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file elastic-git-0.1.2.tar.gz.

File metadata

  • Download URL: elastic-git-0.1.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for elastic-git-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eabf9495d42301c888a0d17b77c2f2028fe7768682585f7609f176f03163fe6b
MD5 58ff65d2196cf11f807439af7326dda5
BLAKE2b-256 828a5a470f2f34535884121da4d876b5a4b11ec1a1c236db595ea6664fbe32b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page