Goatfish 0.1

A small, schemaless ORM that is backed by SQLite
Goatfish is a small, schemaless ORM that is backed by SQLite.

Goatfish supports persisting arbitrary objects (anything the pickle module can handle) to database and indexing on arbitrary properties of the objects.

Its usage is very simple, just have your classes inherit from goatfish.Model and and specify a connection, and the goatfish methods are available to you. goatfish also supports querying for arbitrary properties in your models, as well as indexing on arbitrary properties. It does not enforce a schema of any kind.

It appears that this method is identical to what FriendFeed used to implement a schemaless layer over MySQL, which is pretty significant validation:

http://backchannel.org/blog/friendfeed-schemaless-mysql

Installation

You have multiple options of installation:

- With pip (preferred), do pip install goatfish.
- With setuptools, do easy_install goatfish.
- To install the source, download it from https://github.com/stochastic-technologies/goatfish/ and do python setup.py install.

Usage

To use goatfish, all you need to do is create a class that inherits from goatfish.Model:

import goatfish
import sqlite3

class Test(goatfish.Model):
 class Meta:
 # This is so we know where to connect.
 connection = sqlite3.connect(":memory:")


# Create the necessary tables. If they exist, do nothing.
Test.initialize()

foo = Test()
foo.bar = "hello"
foo.save()

# Retrieve all elements.
>>> [test.bar for test in Test.find()]
['hello']

# Run a query with parameters (slow, loads every item from the DB to check it).
>>> [test.bar for test in Test.find({"bar": "hello"})]
['hello']

# Run a query with a parameter that doesn't exist in the dataset.
>>> [test.bar for test in Test.find({"bar": "hello", "baz": "hi"})]
[]

# Delete the element.
>>> foo.delete()

# Try to retrieve all elements again.
>>> [test.bar for test in Test.find()]
[]

last updated on:
February 16th, 2012, 17:49 GMT
price:
FREE!
developed by:
Stochastic Technologies
homepage:
github.com
license type:
BSD License 
category:
ROOT \ Information Management

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Add your review!

SUBMIT