Nothing Special   »   [go: up one dir, main page]

Skip to content

richhickey/sdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

sdb

A Clojure library for working with Amazon SimpleDB
, (docs)

Built on top of Amazon’s Java API for SimpleDB
, (javadocs)

The library lets you directly save and load Clojure data, and query using data. No strings! Stores using lexicographically-sortable representations. Can store strings, keywords, ints, longs, Dates, booleans and UUIDs, and can be extended to other primitives.

The dependencies can be downloaded from the downloads area

Usage

(use 'org.clojure.sdb)

(def aws-key "[...]")
(def aws-secret-key "[...]")
(def client (create-client aws-key aws-secret-key))

(put-attrs client "heroes" {:sdb/id "spiderman"
                            :power "spidery-things"
                            :secret-identity "Peter Parker"})

(put-attrs client "heroes" {:sdb/id "hulk"
                            :power "huge angry thing"
                            :secret-identity "Bruce Banner"})

(put-attrs client "heroes" {:sdb/id "venom"
                            :power "spidery-things"
                            :secret-identity "Eddie Brock"
                            :evil true})

(get-attrs client "heroes" "spiderman")
;; {:secret-identity "Peter Parker", :power "spidery-things", :sdb/id "spiderman"}

(query client '{:select [:secret-identity] :from "heroes" :where (= :evil true)})
;; ({:secret-identity "Eddie Brock", :sdb/id "venom"})

Local Use

It’s not always desirable to connect to a live server when using SimpleDB since you get charged (a small amount) for every transaction, and you won’t be able to develop while offline. To develop against a local SimpleDB mock, download and install SimpleDB-dev and configure your client to use an alternate service URL:

$ wget http://simpledb-dev.googlecode.com/files/simpledb-dev-0.1.10.zip
$ unzip simpledb-dev-0.1.10.zip
$ python SimpleDB-Dev/src/simpledb_dev.py &

In your code:

(create-client my-sdb-key my-sdb-secret-key
               (.withServiceURL (com.amazonaws.sdb.AmazonSimpleDBConfig.)
                                "http://localhost:8080")))

About

A Clojure library for working with Amazon SimpleDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published