SlideShare a Scribd company logo
1 of 40
Download to read offline
CouchDB & Django
                          avec CouchDBkit
                               Benoît Chesneau
                           25/04/2010 - djangocong
Sunday, April 25, 2010
benoît chesneau

              benoitc@apache.org
              Artisan web
              Minimal web & Opensource
              Enki Multimedia
              http://www.e-engura.com



Sunday, April 25, 2010
• Pourquoi utiliser une solution “NoSQL” ?
                     • CouchDB
                     • CouchDBKit: CouchDB & Django


Sunday, April 25, 2010
Pourquoi ?

                     • On a pas forcement besoin de “scalabilité”
                     • Maj des bases de données < 300 Go (2 Go)
                     • Souvent les requêtes sont rapides
                     • Tout tient sur une machine

Sunday, April 25, 2010
Souplesse

                     • Differents types de contenu
                     • Supprimer les “content-types”
                     • Faire de la dénormalisation simplement
                     • Gérer la migration de données/schema
                         facilement



Sunday, April 25, 2010
Garder ses données



Sunday, April 25, 2010
Ex: boutique en ligne

                                       Données
                          Commande                Livraison
                                        clients



                         Item   Item




Sunday, April 25, 2010
• Gérer des differents produits
                     • Sauver une commande avec le détail des
                         produits

                     • à un instant T (le produit est figé)
                     • Ne pas perdre la commande
                     • Ne pas perdre les infos de livraisons et
                         clients


Sunday, April 25, 2010
CouchDB
                     • Base de données orientées document
                     • REST
                     • Map/Reduce (M/R)
                     • Append-Only
                     • Javascript/Erlang
                     • Réplication
Sunday, April 25, 2010
Orientée Document?

                     • Pas de schema
                     • JSON
                     • Attachements


Sunday, April 25, 2010
DOCUMENT JSON

            {
                   "_id": "foo",
                   "_rev": "1-....",
                   "url": "http://apache.couchdb.org",
                   "vote": 1
            }




Sunday, April 25, 2010
Map/Reduce ?
                     • Map (M) : Collecter une liste de valeurs en
                         fonction d’une clé
                     • Retourne une liste de clés/valeurs (K/V)
                     • Reduce (R) : Réduire une liste de clés/
                         valeurs en une liste de valeurs
                     • Rereduce

Sunday, April 25, 2010
MAP.JS
                             function(doc) {
                               if (doc.url && doc.vote)
                                 emit(doc.url, doc.vote);
                             }

                         {
                             "total_rows":3,
                             "offset":0,
                             "rows": [
                             {
                                "id":"15c92051cc81d564db4337a05087bc8d",
                                "key":"http://apache.couchdb.org",
                                "value":1
                             },
                             {
                                "id":"fa9658810d25cac893748e4ff15e7253",
                                "key":"http://apache.couchdb.org",
                                "value":1
                             },
                             {
                                "id":"1fa0c68d8455196507b8b01645e65186",
                                "key":"http://mysql.com",
                                "value":-1
                             }
Sunday, April 25, 2010
REDUCE.JS
                         function(keys, values, rereduce) {
                           return sum(values);
                         }

                             {
                                  "rows":[
                                  {
                                     "key": "http://mysql.com",
        json                         "value": -1

       result                     },
                                  {
                                     "key": "http://apache.couchdb.org",
                                     "value": 2
                                  }
                             ]}




Sunday, April 25, 2010
Futon
Sunday, April 25, 2010
Réplicatuon

                     • Incrémentale
                     • Master-Master
                     • Continue ou à la demande


Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
Sunday, April 25, 2010
CouchDBKit
                     • CouchDB Python framework
                     • supporte CouchDB 0.10.2 & 0.11.0
                     • Client simple
                     • Schema
                     • Extension django
                     • Compatible couchapp
Sunday, April 25, 2010
client
                         from couchdbkit import Server

                         s = Server("http://127.0.0.1:5984")
                         db = s["mydb"]

                         doc = { "a": 1 }
                         db.save_doc(doc)

                         doc["b"] = 2

                         db.save(doc)

                         doc1 = db.get(doc['_id'])




Sunday, April 25, 2010
Autres fonctions


                     • db.views
                     • from couchdbkit.loaders import
                         FileSystemDocsLoader




Sunday, April 25, 2010
from couchdbkit.loaders import FileSystemDocsLoader

               loader = FileSystemDocsLoader('/path/to/example/_design')
               loader.sync(db, verbose=True)


Sunday, April 25, 2010
schema
                         from couchdbkit.schema import *

                         class MyDoc(Document):
                             a = IntegerProperty()

                         contain(db, MyDoc)

                         doc = MyDoc()
                         doc.a = 1
                         doc.save()

                         doc.b = 2
                         doc.save()

                         doc1 = MyDoc.get(doc._id)



Sunday, April 25, 2010
Extension Django

                     • from couchdbkt.ext.django import *
                     • Django helper
                     • manage.py syncdb
                     • DocumentForm

Sunday, April 25, 2010
settings.py
                ...

                COUCHDB_DATABASES = (
                     ('djangoapp.greeting', 'http://127.0.0.1:5984/
                greeting'),
                 )

                   ...

                   INSTALLED_APPS = (
                       ....
                       'couchdbkit.ext.django',
                       'djangoapp.greeting',
                       ....
                   )




Sunday, April 25, 2010
models.py
                     from datetime import datetime
                     from couchdbkit.ext.django.schema import *

                         class Greeting(Document):
                             author = StringProperty()
                             content = StringProperty(required=True)
                             date = DateTimeProperty(default=datetime.utcnow)




Sunday, April 25, 2010
forms.py

                         class GreetingForm(DocumentForm):
                             class Meta:
                                 document = Greeting




Sunday, April 25, 2010
views.py
                         def home(request):
                            greet = None
                            if request.POST:
                                form = GreetingForm(request.POST)
                                if form.is_valid():
                                     greet = form.save()
                            else:
                                  form = GreetingForm()

                            greetings = Greeting.view("greeting/all")

                            return render("home.html", {
                                    "form": form,
                                    "greet": greet,
                                    "greetings": greetings
                            }, context_instance=RequestContext(request))


Sunday, April 25, 2010
0.5

                     • Nouveau mapper àla sqlalchemy
                     • Intégration de futon dans l’admin
                     • Gestion de design docs ameliorée
                     • Support Eventlet
                     • ...

Sunday, April 25, 2010
Sunday, April 25, 2010
Liens


                     • http://apache.couchdb.org
                     • http://couchdbkit.org


Sunday, April 25, 2010
Questions




Sunday, April 25, 2010
@benoitc




Sunday, April 25, 2010
Cette création est mise à disposition selon le Contrat
                         Paternité 2.0 France disponible en ligne http://
                    creativecommons.org/licenses/by/2.0/fr/ ou par courrier
                     postal à Creative Commons, 171 Second Street, Suite
                           300, San Francisco, California 94105, USA.




Sunday, April 25, 2010

More Related Content

What's hot

Getting Started with Dojo Toolkit
Getting Started with Dojo ToolkitGetting Started with Dojo Toolkit
Getting Started with Dojo ToolkitThomas Koch
 
Not Only Drupal
Not Only DrupalNot Only Drupal
Not Only Drupalmcantelon
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
Non-Technical Introduction to CrossRef for Libraries
Non-Technical Introduction to CrossRef for LibrariesNon-Technical Introduction to CrossRef for Libraries
Non-Technical Introduction to CrossRef for LibrariesCrossref
 
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012Blend Interactive
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)iloveigloo
 
Webinar: MongoDB on the JVM
Webinar: MongoDB on the JVMWebinar: MongoDB on the JVM
Webinar: MongoDB on the JVMMongoDB
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer ToolboxYnon Perek
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureGarann Means
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
The Tech Side of Project Argo
The Tech Side of Project ArgoThe Tech Side of Project Argo
The Tech Side of Project ArgoWesley Lindamood
 
Rails 3 Beginner to Builder 2011 Week 2
Rails 3 Beginner to Builder 2011 Week 2Rails 3 Beginner to Builder 2011 Week 2
Rails 3 Beginner to Builder 2011 Week 2Richard Schneeman
 

What's hot (16)

Getting Started with Dojo Toolkit
Getting Started with Dojo ToolkitGetting Started with Dojo Toolkit
Getting Started with Dojo Toolkit
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Not Only Drupal
Not Only DrupalNot Only Drupal
Not Only Drupal
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
jQuery Objects
jQuery ObjectsjQuery Objects
jQuery Objects
 
Java7 normandyjug
Java7 normandyjugJava7 normandyjug
Java7 normandyjug
 
Non-Technical Introduction to CrossRef for Libraries
Non-Technical Introduction to CrossRef for LibrariesNon-Technical Introduction to CrossRef for Libraries
Non-Technical Introduction to CrossRef for Libraries
 
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012
"Searching with Solr" - Tyler Harms, South Dakota Code Camp 2012
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 
Webinar: MongoDB on the JVM
Webinar: MongoDB on the JVMWebinar: MongoDB on the JVM
Webinar: MongoDB on the JVM
 
jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
 
Frontend Engineer Toolbox
Frontend Engineer ToolboxFrontend Engineer Toolbox
Frontend Engineer Toolbox
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer Architecture
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
The Tech Side of Project Argo
The Tech Side of Project ArgoThe Tech Side of Project Argo
The Tech Side of Project Argo
 
Rails 3 Beginner to Builder 2011 Week 2
Rails 3 Beginner to Builder 2011 Week 2Rails 3 Beginner to Builder 2011 Week 2
Rails 3 Beginner to Builder 2011 Week 2
 

Viewers also liked

Interviu Carmen Holotescu
Interviu Carmen HolotescuInterviu Carmen Holotescu
Interviu Carmen Holotescumagdutza
 
Retirement Calculator
Retirement CalculatorRetirement Calculator
Retirement Calculatorfpcksc
 
Pecha kucha live binders2
Pecha kucha live binders2Pecha kucha live binders2
Pecha kucha live binders2Laurie Hnatiuk
 
21st Century Super Student
21st Century Super Student21st Century Super Student
21st Century Super StudentCandace Benson
 
NOAA NESDIS Independent Review Team - Assessment update one year later
NOAA NESDIS Independent Review Team - Assessment update one year laterNOAA NESDIS Independent Review Team - Assessment update one year later
NOAA NESDIS Independent Review Team - Assessment update one year laterclimate central
 
Explaining Extreme Events of 2012 from a Climate Perspective
Explaining Extreme Events of 2012 from a Climate PerspectiveExplaining Extreme Events of 2012 from a Climate Perspective
Explaining Extreme Events of 2012 from a Climate Perspectiveclimate central
 
Education In the United States and Innovative Solutions
Education In the United States and Innovative SolutionsEducation In the United States and Innovative Solutions
Education In the United States and Innovative SolutionsRyan Schrenk
 
Breve GuíA Ilustrada Para Entender El Islam Spanish
Breve GuíA Ilustrada Para Entender El Islam SpanishBreve GuíA Ilustrada Para Entender El Islam Spanish
Breve GuíA Ilustrada Para Entender El Islam SpanishAbdullah Baspren
 
Fundamental issues of Enterprise Systems
Fundamental issues of Enterprise SystemsFundamental issues of Enterprise Systems
Fundamental issues of Enterprise SystemsJohan Magnusson
 
Preparing for the Rising Tide: Executive Summary
Preparing for the Rising Tide: Executive SummaryPreparing for the Rising Tide: Executive Summary
Preparing for the Rising Tide: Executive Summaryclimate central
 
Questo è MUHAMMAD _Italian
Questo è  MUHAMMAD _ItalianQuesto è  MUHAMMAD _Italian
Questo è MUHAMMAD _ItalianAbdullah Baspren
 
Waterstone Master Deck / July 2010
Waterstone Master Deck / July 2010Waterstone Master Deck / July 2010
Waterstone Master Deck / July 2010robertrichards
 
En Kort Illustreret Guide Til ForståElsen Af Islam Danish
En Kort Illustreret Guide Til ForståElsen Af Islam   DanishEn Kort Illustreret Guide Til ForståElsen Af Islam   Danish
En Kort Illustreret Guide Til ForståElsen Af Islam DanishAbdullah Baspren
 

Viewers also liked (20)

Interviu Carmen Holotescu
Interviu Carmen HolotescuInterviu Carmen Holotescu
Interviu Carmen Holotescu
 
Retirement Calculator
Retirement CalculatorRetirement Calculator
Retirement Calculator
 
Pecha kucha live binders2
Pecha kucha live binders2Pecha kucha live binders2
Pecha kucha live binders2
 
21st Century Super Student
21st Century Super Student21st Century Super Student
21st Century Super Student
 
NOAA NESDIS Independent Review Team - Assessment update one year later
NOAA NESDIS Independent Review Team - Assessment update one year laterNOAA NESDIS Independent Review Team - Assessment update one year later
NOAA NESDIS Independent Review Team - Assessment update one year later
 
God Or Allah
God Or AllahGod Or Allah
God Or Allah
 
Ea 3.0
Ea 3.0Ea 3.0
Ea 3.0
 
Explaining Extreme Events of 2012 from a Climate Perspective
Explaining Extreme Events of 2012 from a Climate PerspectiveExplaining Extreme Events of 2012 from a Climate Perspective
Explaining Extreme Events of 2012 from a Climate Perspective
 
Miracle In The Eye
Miracle In The EyeMiracle In The Eye
Miracle In The Eye
 
Miracle In The Cell
Miracle In The CellMiracle In The Cell
Miracle In The Cell
 
Education In the United States and Innovative Solutions
Education In the United States and Innovative SolutionsEducation In the United States and Innovative Solutions
Education In the United States and Innovative Solutions
 
Reading john dearden
Reading john deardenReading john dearden
Reading john dearden
 
Misión Joven Tala 2016
Misión Joven Tala 2016Misión Joven Tala 2016
Misión Joven Tala 2016
 
Breve GuíA Ilustrada Para Entender El Islam Spanish
Breve GuíA Ilustrada Para Entender El Islam SpanishBreve GuíA Ilustrada Para Entender El Islam Spanish
Breve GuíA Ilustrada Para Entender El Islam Spanish
 
Fundamental issues of Enterprise Systems
Fundamental issues of Enterprise SystemsFundamental issues of Enterprise Systems
Fundamental issues of Enterprise Systems
 
Preparing for the Rising Tide: Executive Summary
Preparing for the Rising Tide: Executive SummaryPreparing for the Rising Tide: Executive Summary
Preparing for the Rising Tide: Executive Summary
 
Questo è MUHAMMAD _Italian
Questo è  MUHAMMAD _ItalianQuesto è  MUHAMMAD _Italian
Questo è MUHAMMAD _Italian
 
Deep Thinking
Deep ThinkingDeep Thinking
Deep Thinking
 
Waterstone Master Deck / July 2010
Waterstone Master Deck / July 2010Waterstone Master Deck / July 2010
Waterstone Master Deck / July 2010
 
En Kort Illustreret Guide Til ForståElsen Af Islam Danish
En Kort Illustreret Guide Til ForståElsen Af Islam   DanishEn Kort Illustreret Guide Til ForståElsen Af Islam   Danish
En Kort Illustreret Guide Til ForståElsen Af Islam Danish
 

Similar to CouchDB & Django avec CouchDBkit

Drupal 7: What's In It For You?
Drupal 7: What's In It For You?Drupal 7: What's In It For You?
Drupal 7: What's In It For You?karschsp
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.Jurriaan Persyn
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewAntonio Pintus
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao IntroductionBooch Lin
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!Daniel Cousineau
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Aaron Blythe
 
Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMOrtus Solutions, Corp
 
Introduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal devIntroduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal devmcantelon
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeMichael Ducy
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGuillaume Laforge
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino apiOliver Busse
 

Similar to CouchDB & Django avec CouchDBkit (20)

ActiveRecord 2.3
ActiveRecord 2.3ActiveRecord 2.3
ActiveRecord 2.3
 
Paul Querna - libcloud
Paul Querna - libcloudPaul Querna - libcloud
Paul Querna - libcloud
 
Drupal 7: What's In It For You?
Drupal 7: What's In It For You?Drupal 7: What's In It For You?
Drupal 7: What's In It For You?
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.
 
No sql Database
No sql DatabaseNo sql Database
No sql Database
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao Introduction
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
WSGI, Django, Gunicorn
WSGI, Django, GunicornWSGI, Django, Gunicorn
WSGI, Django, Gunicorn
 
Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013
 
Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORM
 
Stackato v2
Stackato v2Stackato v2
Stackato v2
 
Web Ninja
Web NinjaWeb Ninja
Web Ninja
 
Introduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal devIntroduction to Node.js: perspectives from a Drupal dev
Introduction to Node.js: perspectives from a Drupal dev
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as Code
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
Hadoop - Introduction to Hadoop
Hadoop - Introduction to HadoopHadoop - Introduction to Hadoop
Hadoop - Introduction to Hadoop
 
An intro to Azure Data Lake
An intro to Azure Data LakeAn intro to Azure Data Lake
An intro to Azure Data Lake
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

CouchDB & Django avec CouchDBkit

  • 1. CouchDB & Django avec CouchDBkit Benoît Chesneau 25/04/2010 - djangocong Sunday, April 25, 2010
  • 2. benoît chesneau benoitc@apache.org Artisan web Minimal web & Opensource Enki Multimedia http://www.e-engura.com Sunday, April 25, 2010
  • 3. • Pourquoi utiliser une solution “NoSQL” ? • CouchDB • CouchDBKit: CouchDB & Django Sunday, April 25, 2010
  • 4. Pourquoi ? • On a pas forcement besoin de “scalabilité” • Maj des bases de données < 300 Go (2 Go) • Souvent les requêtes sont rapides • Tout tient sur une machine Sunday, April 25, 2010
  • 5. Souplesse • Differents types de contenu • Supprimer les “content-types” • Faire de la dénormalisation simplement • Gérer la migration de données/schema facilement Sunday, April 25, 2010
  • 7. Ex: boutique en ligne Données Commande Livraison clients Item Item Sunday, April 25, 2010
  • 8. • Gérer des differents produits • Sauver une commande avec le détail des produits • à un instant T (le produit est figé) • Ne pas perdre la commande • Ne pas perdre les infos de livraisons et clients Sunday, April 25, 2010
  • 9. CouchDB • Base de données orientées document • REST • Map/Reduce (M/R) • Append-Only • Javascript/Erlang • Réplication Sunday, April 25, 2010
  • 10. Orientée Document? • Pas de schema • JSON • Attachements Sunday, April 25, 2010
  • 11. DOCUMENT JSON { "_id": "foo", "_rev": "1-....", "url": "http://apache.couchdb.org", "vote": 1 } Sunday, April 25, 2010
  • 12. Map/Reduce ? • Map (M) : Collecter une liste de valeurs en fonction d’une clé • Retourne une liste de clés/valeurs (K/V) • Reduce (R) : Réduire une liste de clés/ valeurs en une liste de valeurs • Rereduce Sunday, April 25, 2010
  • 13. MAP.JS function(doc) { if (doc.url && doc.vote) emit(doc.url, doc.vote); } { "total_rows":3, "offset":0, "rows": [ { "id":"15c92051cc81d564db4337a05087bc8d", "key":"http://apache.couchdb.org", "value":1 }, { "id":"fa9658810d25cac893748e4ff15e7253", "key":"http://apache.couchdb.org", "value":1 }, { "id":"1fa0c68d8455196507b8b01645e65186", "key":"http://mysql.com", "value":-1 } Sunday, April 25, 2010
  • 14. REDUCE.JS function(keys, values, rereduce) { return sum(values); } { "rows":[ { "key": "http://mysql.com", json "value": -1 result }, { "key": "http://apache.couchdb.org", "value": 2 } ]} Sunday, April 25, 2010
  • 16. Réplicatuon • Incrémentale • Master-Master • Continue ou à la demande Sunday, April 25, 2010
  • 25. CouchDBKit • CouchDB Python framework • supporte CouchDB 0.10.2 & 0.11.0 • Client simple • Schema • Extension django • Compatible couchapp Sunday, April 25, 2010
  • 26. client from couchdbkit import Server s = Server("http://127.0.0.1:5984") db = s["mydb"] doc = { "a": 1 } db.save_doc(doc) doc["b"] = 2 db.save(doc) doc1 = db.get(doc['_id']) Sunday, April 25, 2010
  • 27. Autres fonctions • db.views • from couchdbkit.loaders import FileSystemDocsLoader Sunday, April 25, 2010
  • 28. from couchdbkit.loaders import FileSystemDocsLoader loader = FileSystemDocsLoader('/path/to/example/_design') loader.sync(db, verbose=True) Sunday, April 25, 2010
  • 29. schema from couchdbkit.schema import * class MyDoc(Document): a = IntegerProperty() contain(db, MyDoc) doc = MyDoc() doc.a = 1 doc.save() doc.b = 2 doc.save() doc1 = MyDoc.get(doc._id) Sunday, April 25, 2010
  • 30. Extension Django • from couchdbkt.ext.django import * • Django helper • manage.py syncdb • DocumentForm Sunday, April 25, 2010
  • 31. settings.py ... COUCHDB_DATABASES = ( ('djangoapp.greeting', 'http://127.0.0.1:5984/ greeting'), ) ... INSTALLED_APPS = ( .... 'couchdbkit.ext.django', 'djangoapp.greeting', .... ) Sunday, April 25, 2010
  • 32. models.py from datetime import datetime from couchdbkit.ext.django.schema import * class Greeting(Document): author = StringProperty() content = StringProperty(required=True) date = DateTimeProperty(default=datetime.utcnow) Sunday, April 25, 2010
  • 33. forms.py class GreetingForm(DocumentForm): class Meta: document = Greeting Sunday, April 25, 2010
  • 34. views.py def home(request): greet = None if request.POST: form = GreetingForm(request.POST) if form.is_valid(): greet = form.save() else: form = GreetingForm() greetings = Greeting.view("greeting/all") return render("home.html", { "form": form, "greet": greet, "greetings": greetings }, context_instance=RequestContext(request)) Sunday, April 25, 2010
  • 35. 0.5 • Nouveau mapper àla sqlalchemy • Intégration de futon dans l’admin • Gestion de design docs ameliorée • Support Eventlet • ... Sunday, April 25, 2010
  • 37. Liens • http://apache.couchdb.org • http://couchdbkit.org Sunday, April 25, 2010
  • 40. Cette création est mise à disposition selon le Contrat Paternité 2.0 France disponible en ligne http:// creativecommons.org/licenses/by/2.0/fr/ ou par courrier postal à Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. Sunday, April 25, 2010