SlideShare une entreprise Scribd logo
1  sur  84
Télécharger pour lire hors ligne
CouchDB
     relax
Who am I?

{
	   "name": "Myles Braithwaite",
	   "job": "Web Developer",
	   "url": "http://mylesbraithwaite.com",
	   "twitter": "http://twitter.com/mylesb",
	   "xmpp": "me@mylesbraithwaite.com",
	   "email": "me@mylesbraithwaite.com"
}
Monkey in your Soul

$ curl -X GET --head monkeyinyoursoul.com
HTTP/1.1 200 OK
X-Name: Monkey in your Soul
X-URL: monkeyinyoursoul.com
X-Email: info@monkeyinyoursoul.com
X-Twitter: http://twitter.com/miys
X-Owner: Myles Braithwaite
X-Owner-Email: myles@monkeyinyoursoul.com
What is CouchDB?
Document-Oriented
    Database
No Rows or Columns
But
Collection of JSON
    Documents
This is know as
“Schema-Free”
{
	   "fn": "Myles Braithwaite",
	   "emails": [
	   	 "me@myles.tk",
	   	 "myles@miys.net"
	   ],
	   "company": "Monkey in your Soul"
}
<person>
	 <fn>Myels Braithwaite</fn>
	 <emails>
	 	 <email>me@myles.tk</email>
	 	 <email>myles@miys.net</email>
	 </emails>
	 <company>Monkey in your Soul</company>
</person>
Data types
"number": 1
"floating_point": 1.11035
"string": "Hello, World!"
"boolean": true
"array": [1, 2, 3]
"object": {
	 1: "one",
	 2: "two",
	 3: "three"
}
"null": null
HTTP RESTFul API
“CouchDB is built of the
Web”
          - Jacob Kaplan-Moss
Read the RFC 2616
    http://bit.ly/rfc2616
REST

• Representational State Transfer
• The foundation of Web
 • basic HTTP methods like:
   • POST, GET, PUT, and DELETE
Think low level
XML-RPC and SOAP
HTTP Methods              CRUD
   POST            Create and Update

    GET                    Read

    PUT            Create and Replace

  DELETE                  Delete

     http://bit.ly/rfc2616-sec9
201 Created      Created a Document


   200 OK               Succeeded

404 Object Not     Document does not
    Found               Exist

     http://bit.ly/rfc2616-sec10
Views
Aggregation
and Reporting on
   Documents
But how do you
     aggregate
non-structured data?
Instead of using SQL
JavaScript
Distributed
Using Replication
You have your
  Database.
You
You want to share.
You   Friend
Full Control
Bi-Directional Changes
You   Friend
Built in Conflict
  Detection
Using the API
Database
Create a Database


$ curl -v -X PUT $COUCHDB/address_book/

PUT /address_book/
Host: 127.0.0.1:5984
HTTP/1.1 201 Created
Server: CouchDB/0.9.1 (Erlang OTP/R12B)

{"ok":true}
HTTP/1.1 412 Precondition Failed
Server: CouchDB/0.9.1 (Erlang OTP/R12B)

{"error":"file_exists","reason":"The
database could not be created, the file
already exists."}
CREATE TABLE "people" (
	 "id" SERIAL PRIMARY KEY,
	 "fn" VARCHAR(50),
	 "company" VARCHAR(50)
);

CREATE TABLE "person_emails" (
	 "id" SERIAL PRIMARY KEY,
	 "email" VARCHAR(50),
	 "person_id" INTEGER REFERENCES people(id)
);
Delete a Database


$ curl -v -X DELETE $COUCHDB/address_book/

DELETE /address_book/ HTTP/1.1
Host: 127.0.0.1:5984
HTTP/1.1 200 OK
Server: CouchDB/0.9.1 (Erlang OTP/R12B)
Date: Thu, 08 Oct 2009 15:11:31 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 12
Cache-Control: must-revalidate

{"ok":true}
Fetching all Rows

$ curl -v -X GET $COUCHDB/address_book/
_all_docs

GET /address_book/_all_docs HTTP/1.1
Host: 127.0.0.1:5984
HTTP/1.1 200 OK
Server: CouchDB/0.9.1 (Erlang OTP/R12B)
Date: Thu, 22 Oct 2009 13:12:05 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 12
Cache-Control: must-revalidate

{"total_rows":1,"offset":0,"rows":[
{"id":"9c118d4acfcdd1bc0687bcaa53c53674","
key":"9c118d4acfcdd1bc0687bcaa53c53674","v
alue":{"rev":"1-180621101"}}
]}
{
	   "total_rows": 1,
	   "offset": 0,
	   "rows": [
	   	 {
	   	 	 "id": "9c118d4acfcdd1...",
	   	 	 "key": "9c118d4acfcdd1...",
	   	 	 "value": {
	   	 	 	 "rev":"1-180621101"
	   	 	 }
	   	 }
	   ]
}
Document
Creating a Document

curl -v -X POST $COUCHDB/address_book -d
'{"fn": "Myles Braithwaite", "emails":
["me@myles.tk","myles@miys.net"],"company"
:"Monkey in your Soul"}'

POST /address_book HTTP/1.1
Host: 127.0.0.1:5984
Content-Length: 103
HTTP/1.1 201 Created
Location: http://127.0.0.1:5984/
address_book/
9c118d4acfcdd1bc0687bcaa53c53674

{"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5
3c53674","rev":"1-180621101"}
INSERT INTO people ("fn", "company") VALUES
('Myles Braithwaite', 'Monkey in your Soul');
INSERT INTO person_emails ("email", "person_id")
VALUES ('me@myles.tk', 1);
INSERT INTO person_emails ("email", "person_id")
VALUES ('myles@miys.net', 1);
Get a Document

curl -v -X GET $COUCHDB/address_book/
9c118d4acfcdd1bc0687bcaa53c53674

GET /address_book/
9c118d4acfcdd1bc0687bcaa53c53674 HTTP/1.1
Host: 127.0.0.1:5984
HTTP/1.1 200 OK
Server: CouchDB/0.9.1 (Erlang OTP/R13B)
Etag: "1-180621101"

{"_id":"9c118d4acfcdd1bc0687bcaa53c53674",
"_rev":"1-180621101","fn":"Myles
Braithwaite","emails":
["me@myles.tk","myles@miys.net"],"company"
:"Monkey in your Soul"}
{
	 "_id":
"9c118d4acfcdd1bc0687bcaa53c53674",
	 "_rev": "1-180621101",
	 "fn": "Myles Braithwaite",
	 "emails": [
	 	 "me@myles.tk",
	 	 "myles@miys.net"
	 ],
	 "company":"Monkey in your Soul"
}
Update a Document
curl -v -X PUT $COUCHDB/address_book/
9c118d4acfcdd1bc0687bcaa53c53674 -d
'{"_id":"9c118d4acfcdd1bc0687bcaa53c53674"
,"_rev":"1-180621101","fn":"Myles
Braithwaite","emails":
["me@myles.tk","myles@miys.net"],"company"
:"Monkey in your Soul","urls":["http://
twitter.com/mylesb","http://
mylesbraithwaite.com/"]}'
Update a Document
curl -v -X PUT $COUCHDB/address_book/
9c118d4acfcdd1bc0687bcaa53c53674 -d
'{"_id":"9c118d4acfcdd1bc0687bcaa53c53674"
,"_rev":"1-180621101","fn":"Myles
Braithwaite","emails":
["me@myles.tk","myles@miys.net"],"company"
:"Monkey in your Soul","urls":["http://
twitter.com/mylesb","http://
mylesbraithwaite.com/"]}'
PUT /address_book/
9c118d4acfcdd1bc0687bcaa53c53674 HTTP/1.1
Host: 127.0.0.1:5984
HTTP/1.1 201 Created
Server: CouchDB/0.9.1 (Erlang OTP/R13B)
Etag: "2-2080422110"

{"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5
3c53674","rev":"2-2080422110"}
Attaching a File to a
     Document
curl -v -X PUT $COUCHDB/address_book/
215422c46959ffc1bd875b025e8d1360/
photo.jpg?rev=5-2484899332 --data-binary
@photo.jpg -H 'Content-Type: image/jpeg'

PUT /address_book/
215422c46959ffc1bd875b025e8d1360/
photo.jpg?rev=5-2484899332 HTTP/1.1
Host: 127.0.0.1:5984
Content-Type: image/jpeg
Content-Length: 25565
Expect: 100-continue
HTTP/1.1 201 Created
Server: CouchDB/0.9.1 (Erlang OTP/R13B)
Content-Type: text/plain;charset=utf-8

{"ok":true,"id":"215422c46959ffc1bd875b025
e8d1360","rev":"6-3885229966"}
curl -v -X GET $COUCHDB/address_book/
215422c46959ffc1bd875b025e8d1360/photo.jpg

GET /address_book/
215422c46959ffc1bd875b025e8d1360/photo.jpg
HTTP/1.1
Host: 127.0.0.1:5984
Copy a Document

curl -v -X COPY $COUCHDB/address_book/
215422c46959ffc1bd875b025e8d1360 -H
'Destination: myles-braithwaite'

COPY /address_book/
215422c46959ffc1bd875b025e8d1360 HTTP/1.1
Host: 127.0.0.1:5984
Destination: myles-braithwaite
HTTP/1.1 201 Created
Server: CouchDB/0.9.1 (Erlang OTP/R13B)
Etag: "1-4208662590"

{"rev":"1-4208662590"}
Delete a Document

curl -v -X DELETE $COUCHDB/address_book/
9c118d4acfcdd1bc0687bcaa53c53674?
rev=2-2080422110

DELETE /address_book/
9c118d4acfcdd1bc0687bcaa53c53674?
rev=2-2080422110 HTTP/1.1
Host: 127.0.0.1:5984
HTTP/1.1 200 OK
Server: CouchDB/0.9.1 (Erlang OTP/R13B)
Etag: "3-3181309232"

{"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5
3c53674","rev":"3-3181309232"}
Demo Futon
Libraries
Python


• http://code.google.com/p/couchdb-python/
Ruby


• http://github.com/jchris/couchrest
Erlang


• http://bitbucket.org/benoitc/couchbeam/
Java


• http://code.google.com/p/couchdb4j/
I have created a Library
    in an afternoon.
"""
Copyright 2009 Myles Braithwaite <me@mylesbraithwaite.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import urllib, base64, string

import simplejson
import httplib2

class Couch(object):
	        """
	        :param host: The full URI to the CouchDB host.
	        :params username password: The username and password to login.
	        """
	        def __init__(self, uri='http://127.0.0.1:5984', username=None, password=None):
	        	        self.uri = uri
	        	        self.username = username
	        	        self.password = password
	
	        def _connect(self):
	        	        """Connect to the CouchDB server.
	        	        """
	        	        h = httplib2.Http()
	        	        if self.username and self.password:
	        	        	        h.add_credentials(self.username, self.password)
	        	
	        	        return h
	
	        def _http(self, path, method, headers={}, body=None):
	        	        c = self._connect()
	        	        return c.request('%s%s' % (self.uri, path),
	        	        	        method,
	        	        	        headers=headers,
	        	        	        body=body)
	
	        # Database operations
	
	        def list_databases(self):
	        	        """To get a list of databases on a CouchDB server.
	
	        	        :return: A list of database names.
	        	        :rtype: list
	        	        """
	        	        headers = { "Accept": "application/json" }
	        	        response, content = self._http('/_all_dbs', "GET", headers=headers)
Just shy of 300 lines
• Python: httplib
• Perl: Net::HTTP
• Java: java.net.HttpURLConnection
• Ruby: net/http
I will be at the GTALUG
         Booth at:
         4:00 p.m.
Questions
Other
Document-Oriented
 Database Systems
MongoDB
http://mongodb.org
Amazon SimpleDB
http://aws.amazon.com/simpledb
Photo Credits
•   http://www.flickr.com/    •   http://www.flickr.com/
    photos/                      photos/stewart/
    83737641@N00/237769          99129170/
    1249/
                             •   http://www.flickr.com/
•   http://www.flickr.com/        photos/matthigh/
    photos/                      1817222239/
    dragon2309/1490657223/
                             •   http://www.flickr.com/
•   http://www.flickr.com/        photos/garibaldi/
    photos/vincealongi/          300430036/
    354450827/

Contenu connexe

Tendances

Hd insight programming
Hd insight programmingHd insight programming
Hd insight programmingCasear Chu
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-pythonEric Ahn
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformAvi Networks
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHPDavid de Boer
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
 
Http capturing
Http capturingHttp capturing
Http capturingEric Ahn
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in SwiftPeter Friese
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDBShuai Liu
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-WeltFlorian Hopf
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLGabriela Ferrara
 
Forget the Web
Forget the WebForget the Web
Forget the WebRemy Sharp
 
MongoDB: How it Works
MongoDB: How it WorksMongoDB: How it Works
MongoDB: How it WorksMike Dirolf
 
WSO2Con USA 2015: Securing your APIs: Patterns and More
WSO2Con USA 2015: Securing your APIs: Patterns and MoreWSO2Con USA 2015: Securing your APIs: Patterns and More
WSO2Con USA 2015: Securing your APIs: Patterns and MoreWSO2
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchMichael Lange
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 

Tendances (20)

Hd insight programming
Hd insight programmingHd insight programming
Hd insight programming
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-python
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platform
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHP
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
Http capturing
Http capturingHttp capturing
Http capturing
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Elasticsearch und die Java-Welt
Elasticsearch und die Java-WeltElasticsearch und die Java-Welt
Elasticsearch und die Java-Welt
 
SunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQLSunshinePHP 2017 - Making the most out of MySQL
SunshinePHP 2017 - Making the most out of MySQL
 
Forget the Web
Forget the WebForget the Web
Forget the Web
 
MongoDB: How it Works
MongoDB: How it WorksMongoDB: How it Works
MongoDB: How it Works
 
WSO2Con USA 2015: Securing your APIs: Patterns and More
WSO2Con USA 2015: Securing your APIs: Patterns and MoreWSO2Con USA 2015: Securing your APIs: Patterns and More
WSO2Con USA 2015: Securing your APIs: Patterns and More
 
groovy & grails - lecture 12
groovy & grails - lecture 12groovy & grails - lecture 12
groovy & grails - lecture 12
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job Dispatch
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 

En vedette

Python-CouchDB Training at PyCon PL 2012
Python-CouchDB Training at PyCon PL 2012Python-CouchDB Training at PyCon PL 2012
Python-CouchDB Training at PyCon PL 2012Stefan Kögl
 
Can the Next Steve Jobs be Brazilian
Can the Next Steve Jobs be BrazilianCan the Next Steve Jobs be Brazilian
Can the Next Steve Jobs be BrazilianBenjamin Joffe
 
NoSQL in Perspective
NoSQL in PerspectiveNoSQL in Perspective
NoSQL in PerspectiveJeff Smith
 
GTALUG Presentation on CouchDB
GTALUG Presentation on CouchDBGTALUG Presentation on CouchDB
GTALUG Presentation on CouchDBMyles Braithwaite
 
Rails Couch Db Presentation
Rails Couch Db PresentationRails Couch Db Presentation
Rails Couch Db Presentationleente
 
Introduction into CouchDB / Jan Lehnardt
Introduction into CouchDB / Jan LehnardtIntroduction into CouchDB / Jan Lehnardt
Introduction into CouchDB / Jan LehnardtBBC Web Developers
 
MySQL vs NoSQL - The Innovator's Dilemna
MySQL vs NoSQL - The Innovator's DilemnaMySQL vs NoSQL - The Innovator's Dilemna
MySQL vs NoSQL - The Innovator's Dilemnalenidot
 
Finland in the eyes of LinkedIn
Finland in the eyes of LinkedInFinland in the eyes of LinkedIn
Finland in the eyes of LinkedInTeemu Korpi
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and HowBigBlueHat
 
A Nosql Summer
A Nosql SummerA Nosql Summer
A Nosql SummerTim Lossen
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesKyle Banerjee
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingMyles Braithwaite
 
Introduction to NOSQL quadrants
Introduction to NOSQL quadrantsIntroduction to NOSQL quadrants
Introduction to NOSQL quadrantsViswanath J
 

En vedette (20)

Introducing CouchDB
Introducing CouchDBIntroducing CouchDB
Introducing CouchDB
 
Python-CouchDB Training at PyCon PL 2012
Python-CouchDB Training at PyCon PL 2012Python-CouchDB Training at PyCon PL 2012
Python-CouchDB Training at PyCon PL 2012
 
Can the Next Steve Jobs be Brazilian
Can the Next Steve Jobs be BrazilianCan the Next Steve Jobs be Brazilian
Can the Next Steve Jobs be Brazilian
 
Why CouchDB
Why CouchDBWhy CouchDB
Why CouchDB
 
NoSQL isn't NO SQL
NoSQL isn't NO SQLNoSQL isn't NO SQL
NoSQL isn't NO SQL
 
NoSQL in Perspective
NoSQL in PerspectiveNoSQL in Perspective
NoSQL in Perspective
 
Brief overview of NoSQL & MongoDB for GTUG Tbilisi Event
Brief overview of NoSQL & MongoDB for GTUG Tbilisi EventBrief overview of NoSQL & MongoDB for GTUG Tbilisi Event
Brief overview of NoSQL & MongoDB for GTUG Tbilisi Event
 
CouchDB
CouchDBCouchDB
CouchDB
 
GTALUG Presentation on CouchDB
GTALUG Presentation on CouchDBGTALUG Presentation on CouchDB
GTALUG Presentation on CouchDB
 
Rails Couch Db Presentation
Rails Couch Db PresentationRails Couch Db Presentation
Rails Couch Db Presentation
 
Introduction into CouchDB / Jan Lehnardt
Introduction into CouchDB / Jan LehnardtIntroduction into CouchDB / Jan Lehnardt
Introduction into CouchDB / Jan Lehnardt
 
MySQL vs NoSQL - The Innovator's Dilemna
MySQL vs NoSQL - The Innovator's DilemnaMySQL vs NoSQL - The Innovator's Dilemna
MySQL vs NoSQL - The Innovator's Dilemna
 
NOSQL - not only sql
NOSQL - not only sqlNOSQL - not only sql
NOSQL - not only sql
 
Finland in the eyes of LinkedIn
Finland in the eyes of LinkedInFinland in the eyes of LinkedIn
Finland in the eyes of LinkedIn
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
 
A Nosql Summer
A Nosql SummerA Nosql Summer
A Nosql Summer
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
 
Introduction to NOSQL quadrants
Introduction to NOSQL quadrantsIntroduction to NOSQL quadrants
Introduction to NOSQL quadrants
 

Similaire à Apache CouchDB talk at Ontario GNU Linux Fest

REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and PythonPiXeL16
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
CouchDB : More Couch
CouchDB : More CouchCouchDB : More Couch
CouchDB : More Couchdelagoya
 
OSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBOSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBBradley Holt
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
Apache Camel - The integration library
Apache Camel - The integration libraryApache Camel - The integration library
Apache Camel - The integration libraryClaus Ibsen
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP ApisAdrian Cole
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stackBram Vogelaar
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Giovanni Bechis
 
Managing Your Content with Elasticsearch
Managing Your Content with ElasticsearchManaging Your Content with Elasticsearch
Managing Your Content with ElasticsearchSamantha Quiñones
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache CamelClaus Ibsen
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2Adam Klein
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime WebTrotter Cashion
 

Similaire à Apache CouchDB talk at Ontario GNU Linux Fest (20)

REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
CouchDB : More Couch
CouchDB : More CouchCouchDB : More Couch
CouchDB : More Couch
 
OSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBOSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDB
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Couchdb w Ruby'm
Couchdb w Ruby'mCouchdb w Ruby'm
Couchdb w Ruby'm
 
Apache Camel - The integration library
Apache Camel - The integration libraryApache Camel - The integration library
Apache Camel - The integration library
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP Apis
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD
 
Managing Your Content with Elasticsearch
Managing Your Content with ElasticsearchManaging Your Content with Elasticsearch
Managing Your Content with Elasticsearch
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime Web
 

Plus de Myles Braithwaite

LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingMyles Braithwaite
 
jrnl Presentation @ March 2015 GTALUG Meeting
jrnl Presentation @ March 2015 GTALUG Meetingjrnl Presentation @ March 2015 GTALUG Meeting
jrnl Presentation @ March 2015 GTALUG MeetingMyles Braithwaite
 
The Internet and Your Business
The Internet and Your BusinessThe Internet and Your Business
The Internet and Your BusinessMyles Braithwaite
 
GTALUG Short Talk On Mercurial
GTALUG Short Talk On MercurialGTALUG Short Talk On Mercurial
GTALUG Short Talk On MercurialMyles Braithwaite
 
So You Want A Personal Website?
So You Want A Personal Website?So You Want A Personal Website?
So You Want A Personal Website?Myles Braithwaite
 

Plus de Myles Braithwaite (9)

Take a Stroll in the Bazaar
Take a Stroll in the BazaarTake a Stroll in the Bazaar
Take a Stroll in the Bazaar
 
LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG Meeting
 
jrnl Presentation @ March 2015 GTALUG Meeting
jrnl Presentation @ March 2015 GTALUG Meetingjrnl Presentation @ March 2015 GTALUG Meeting
jrnl Presentation @ March 2015 GTALUG Meeting
 
The Internet and Your Business
The Internet and Your BusinessThe Internet and Your Business
The Internet and Your Business
 
The Devil and HTML5
The Devil and HTML5The Devil and HTML5
The Devil and HTML5
 
GTALUG Short Talk On Mercurial
GTALUG Short Talk On MercurialGTALUG Short Talk On Mercurial
GTALUG Short Talk On Mercurial
 
So You Want A Personal Website?
So You Want A Personal Website?So You Want A Personal Website?
So You Want A Personal Website?
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Django GTALUG Presentation
Django GTALUG PresentationDjango GTALUG Presentation
Django GTALUG Presentation
 

Dernier

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Dernier (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Apache CouchDB talk at Ontario GNU Linux Fest

  • 1. CouchDB relax
  • 2. Who am I? { "name": "Myles Braithwaite", "job": "Web Developer", "url": "http://mylesbraithwaite.com", "twitter": "http://twitter.com/mylesb", "xmpp": "me@mylesbraithwaite.com", "email": "me@mylesbraithwaite.com" }
  • 3. Monkey in your Soul $ curl -X GET --head monkeyinyoursoul.com HTTP/1.1 200 OK X-Name: Monkey in your Soul X-URL: monkeyinyoursoul.com X-Email: info@monkeyinyoursoul.com X-Twitter: http://twitter.com/miys X-Owner: Myles Braithwaite X-Owner-Email: myles@monkeyinyoursoul.com
  • 5. Document-Oriented Database
  • 6. No Rows or Columns
  • 7. But
  • 8. Collection of JSON Documents
  • 9. This is know as “Schema-Free”
  • 10. { "fn": "Myles Braithwaite", "emails": [ "me@myles.tk", "myles@miys.net" ], "company": "Monkey in your Soul" }
  • 11. <person> <fn>Myels Braithwaite</fn> <emails> <email>me@myles.tk</email> <email>myles@miys.net</email> </emails> <company>Monkey in your Soul</company> </person>
  • 13. "number": 1 "floating_point": 1.11035 "string": "Hello, World!" "boolean": true "array": [1, 2, 3] "object": { 1: "one", 2: "two", 3: "three" } "null": null
  • 15. “CouchDB is built of the Web” - Jacob Kaplan-Moss
  • 16. Read the RFC 2616 http://bit.ly/rfc2616
  • 17. REST • Representational State Transfer • The foundation of Web • basic HTTP methods like: • POST, GET, PUT, and DELETE
  • 19. HTTP Methods CRUD POST Create and Update GET Read PUT Create and Replace DELETE Delete http://bit.ly/rfc2616-sec9
  • 20. 201 Created Created a Document 200 OK Succeeded 404 Object Not Document does not Found Exist http://bit.ly/rfc2616-sec10
  • 21. Views
  • 23. But how do you aggregate non-structured data?
  • 28. You have your Database.
  • 29. You
  • 30. You want to share.
  • 31. You Friend
  • 34. You Friend
  • 35.
  • 36. Built in Conflict Detection
  • 39. Create a Database $ curl -v -X PUT $COUCHDB/address_book/ PUT /address_book/ Host: 127.0.0.1:5984
  • 40. HTTP/1.1 201 Created Server: CouchDB/0.9.1 (Erlang OTP/R12B) {"ok":true}
  • 41. HTTP/1.1 412 Precondition Failed Server: CouchDB/0.9.1 (Erlang OTP/R12B) {"error":"file_exists","reason":"The database could not be created, the file already exists."}
  • 42. CREATE TABLE "people" ( "id" SERIAL PRIMARY KEY, "fn" VARCHAR(50), "company" VARCHAR(50) ); CREATE TABLE "person_emails" ( "id" SERIAL PRIMARY KEY, "email" VARCHAR(50), "person_id" INTEGER REFERENCES people(id) );
  • 43. Delete a Database $ curl -v -X DELETE $COUCHDB/address_book/ DELETE /address_book/ HTTP/1.1 Host: 127.0.0.1:5984
  • 44. HTTP/1.1 200 OK Server: CouchDB/0.9.1 (Erlang OTP/R12B) Date: Thu, 08 Oct 2009 15:11:31 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 12 Cache-Control: must-revalidate {"ok":true}
  • 45. Fetching all Rows $ curl -v -X GET $COUCHDB/address_book/ _all_docs GET /address_book/_all_docs HTTP/1.1 Host: 127.0.0.1:5984
  • 46. HTTP/1.1 200 OK Server: CouchDB/0.9.1 (Erlang OTP/R12B) Date: Thu, 22 Oct 2009 13:12:05 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 12 Cache-Control: must-revalidate {"total_rows":1,"offset":0,"rows":[ {"id":"9c118d4acfcdd1bc0687bcaa53c53674"," key":"9c118d4acfcdd1bc0687bcaa53c53674","v alue":{"rev":"1-180621101"}} ]}
  • 47. { "total_rows": 1, "offset": 0, "rows": [ { "id": "9c118d4acfcdd1...", "key": "9c118d4acfcdd1...", "value": { "rev":"1-180621101" } } ] }
  • 49. Creating a Document curl -v -X POST $COUCHDB/address_book -d '{"fn": "Myles Braithwaite", "emails": ["me@myles.tk","myles@miys.net"],"company" :"Monkey in your Soul"}' POST /address_book HTTP/1.1 Host: 127.0.0.1:5984 Content-Length: 103
  • 50. HTTP/1.1 201 Created Location: http://127.0.0.1:5984/ address_book/ 9c118d4acfcdd1bc0687bcaa53c53674 {"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5 3c53674","rev":"1-180621101"}
  • 51. INSERT INTO people ("fn", "company") VALUES ('Myles Braithwaite', 'Monkey in your Soul'); INSERT INTO person_emails ("email", "person_id") VALUES ('me@myles.tk', 1); INSERT INTO person_emails ("email", "person_id") VALUES ('myles@miys.net', 1);
  • 52. Get a Document curl -v -X GET $COUCHDB/address_book/ 9c118d4acfcdd1bc0687bcaa53c53674 GET /address_book/ 9c118d4acfcdd1bc0687bcaa53c53674 HTTP/1.1 Host: 127.0.0.1:5984
  • 53. HTTP/1.1 200 OK Server: CouchDB/0.9.1 (Erlang OTP/R13B) Etag: "1-180621101" {"_id":"9c118d4acfcdd1bc0687bcaa53c53674", "_rev":"1-180621101","fn":"Myles Braithwaite","emails": ["me@myles.tk","myles@miys.net"],"company" :"Monkey in your Soul"}
  • 54. { "_id": "9c118d4acfcdd1bc0687bcaa53c53674", "_rev": "1-180621101", "fn": "Myles Braithwaite", "emails": [ "me@myles.tk", "myles@miys.net" ], "company":"Monkey in your Soul" }
  • 55. Update a Document curl -v -X PUT $COUCHDB/address_book/ 9c118d4acfcdd1bc0687bcaa53c53674 -d '{"_id":"9c118d4acfcdd1bc0687bcaa53c53674" ,"_rev":"1-180621101","fn":"Myles Braithwaite","emails": ["me@myles.tk","myles@miys.net"],"company" :"Monkey in your Soul","urls":["http:// twitter.com/mylesb","http:// mylesbraithwaite.com/"]}'
  • 56. Update a Document curl -v -X PUT $COUCHDB/address_book/ 9c118d4acfcdd1bc0687bcaa53c53674 -d '{"_id":"9c118d4acfcdd1bc0687bcaa53c53674" ,"_rev":"1-180621101","fn":"Myles Braithwaite","emails": ["me@myles.tk","myles@miys.net"],"company" :"Monkey in your Soul","urls":["http:// twitter.com/mylesb","http:// mylesbraithwaite.com/"]}'
  • 58. HTTP/1.1 201 Created Server: CouchDB/0.9.1 (Erlang OTP/R13B) Etag: "2-2080422110" {"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5 3c53674","rev":"2-2080422110"}
  • 59. Attaching a File to a Document curl -v -X PUT $COUCHDB/address_book/ 215422c46959ffc1bd875b025e8d1360/ photo.jpg?rev=5-2484899332 --data-binary @photo.jpg -H 'Content-Type: image/jpeg' PUT /address_book/ 215422c46959ffc1bd875b025e8d1360/ photo.jpg?rev=5-2484899332 HTTP/1.1 Host: 127.0.0.1:5984 Content-Type: image/jpeg Content-Length: 25565 Expect: 100-continue
  • 60. HTTP/1.1 201 Created Server: CouchDB/0.9.1 (Erlang OTP/R13B) Content-Type: text/plain;charset=utf-8 {"ok":true,"id":"215422c46959ffc1bd875b025 e8d1360","rev":"6-3885229966"}
  • 61. curl -v -X GET $COUCHDB/address_book/ 215422c46959ffc1bd875b025e8d1360/photo.jpg GET /address_book/ 215422c46959ffc1bd875b025e8d1360/photo.jpg HTTP/1.1 Host: 127.0.0.1:5984
  • 62.
  • 63. Copy a Document curl -v -X COPY $COUCHDB/address_book/ 215422c46959ffc1bd875b025e8d1360 -H 'Destination: myles-braithwaite' COPY /address_book/ 215422c46959ffc1bd875b025e8d1360 HTTP/1.1 Host: 127.0.0.1:5984 Destination: myles-braithwaite
  • 64. HTTP/1.1 201 Created Server: CouchDB/0.9.1 (Erlang OTP/R13B) Etag: "1-4208662590" {"rev":"1-4208662590"}
  • 65. Delete a Document curl -v -X DELETE $COUCHDB/address_book/ 9c118d4acfcdd1bc0687bcaa53c53674? rev=2-2080422110 DELETE /address_book/ 9c118d4acfcdd1bc0687bcaa53c53674? rev=2-2080422110 HTTP/1.1 Host: 127.0.0.1:5984
  • 66. HTTP/1.1 200 OK Server: CouchDB/0.9.1 (Erlang OTP/R13B) Etag: "3-3181309232" {"ok":true,"id":"9c118d4acfcdd1bc0687bcaa5 3c53674","rev":"3-3181309232"}
  • 73. I have created a Library in an afternoon.
  • 74. """ Copyright 2009 Myles Braithwaite <me@mylesbraithwaite.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import urllib, base64, string import simplejson import httplib2 class Couch(object): """ :param host: The full URI to the CouchDB host. :params username password: The username and password to login. """ def __init__(self, uri='http://127.0.0.1:5984', username=None, password=None): self.uri = uri self.username = username self.password = password def _connect(self): """Connect to the CouchDB server. """ h = httplib2.Http() if self.username and self.password: h.add_credentials(self.username, self.password) return h def _http(self, path, method, headers={}, body=None): c = self._connect() return c.request('%s%s' % (self.uri, path), method, headers=headers, body=body) # Database operations def list_databases(self): """To get a list of databases on a CouchDB server. :return: A list of database names. :rtype: list """ headers = { "Accept": "application/json" } response, content = self._http('/_all_dbs', "GET", headers=headers)
  • 75. Just shy of 300 lines
  • 76. • Python: httplib • Perl: Net::HTTP • Java: java.net.HttpURLConnection • Ruby: net/http
  • 77.
  • 78.
  • 79. I will be at the GTALUG Booth at: 4:00 p.m.
  • 84. Photo Credits • http://www.flickr.com/ • http://www.flickr.com/ photos/ photos/stewart/ 83737641@N00/237769 99129170/ 1249/ • http://www.flickr.com/ • http://www.flickr.com/ photos/matthigh/ photos/ 1817222239/ dragon2309/1490657223/ • http://www.flickr.com/ • http://www.flickr.com/ photos/garibaldi/ photos/vincealongi/ 300430036/ 354450827/