CouchBase-Python.

CouchBase Python SDK
Scarica ora

CouchBase-Python. Classifica e riepilogo

Annuncio pubblicitario

  • Rating:
  • Licenza:
  • The Apache License 2.0
  • Prezzo:
  • FREE
  • Nome editore:
  • Couchbase, Inc.
  • Sito web dell'editore:
  • http://www.couchbase.com/

CouchBase-Python. Tag


CouchBase-Python. Descrizione

CouchBase-Python è una libreria Python che fornisce metodi per connettersi a entrambe le interfaccia di Couchbase MemCached e l'interfaccia API di COUCHBASE REST.Questa versione richiede Python 2.6 o successive. Dovrai installare i seguenti requisiti della libreria Python tramite PIP: PIP Installa richiesta Problemi: http://www.couchbase.org/issues/browse/pycbcusagetwo Simple Uso Casi da impostare e ottenere una chiave nel secchio predefinito e quindi creare un nuovo secchio utilizzando i client memcached e riposati: #! / Usr / bin / env pythonfrom couchbase.CouchBaseClient importazione couchbaseClientfrom couchbase.CouchBaseClient importazione memcachedtimeoutExceptionFrom CouchBase.Rest_Client Import RESTConnectionClient = CouchBaseClient ("http: // localhost: 8091 / pools / predefinito", client "predefinito", "Key1"). , 0, 0, "Value1") client.get ("Key1") Server_info = {"IP": "localhost", "Porta": 8091, "username": "Amministratore", "Password": "Password"} REST = RESTCONNECTION (server_info) riposo.create_bucket (secchio = 'newbucket', ramquotamb = 100, authtype = 'none', s aslpassword = '', replicanumber = 1, proxyport = 11215, seckttype = 'membase') codice di esempio che crea secchi e quindi imposta, ottiene e visualizza le viste utilizzando il client unificato: import couchbase # connettersi a un couchbase servercb = couchbase.server ( 'localhost: 8091', username = 'amministratore', password = 'Password') # Crea secchio predefinito se non esistono: cb.creare ('default') tranne: Pass # prendi un secchio con encompscriptDefault_bucket = cb # Impostare un valore con pedice (equivilent in .set) predefinito_bucket =' Value1 '# Fetch un secchio con un functionDefault_bucket2 = cb.bucket (' predefinito ') # impostare un valore json con pedice (equivilent per .Set) Default_bucket2 = {'Value': 'Value': 'Value2', 'Expirazione': 0, 'Flags': 10} # Impostare un valore con un valore con un functionDefault_bucket.set ('Key3', 0, 0, 'Value3') # Prendi una chiave con una chiave con una funzione "Key11" + STR (default_bucket.get ('default_bucket.get (' key11 ')) Stampa' Key2 '+ STR (Default_bucket2.get (' default_bucket2.get ('default_ '+ str (default_bucket2 ) # Elimina un secchio B.Delete ('Default') Prova: CB ad eccezione dell'eccezione AS EX: stampa EX # Crea una nuova sesseria: newbucket = cb.create ('newbucket', ram_quota_mb = 100, replica = 1) Tranne: newbucket = cb # Imposta un documento JSON con una funzione # Traduci $ flags e $ Scadenza su MemCached Protocol # Genera automaticamente il _iddoc_id = newbucket.Save ({"Type": "Item", "Value": 'JSON TEST', '$ FLAGS': 25}) Stampa DOC_ID + '' + STR (NEWBUCKET ) # Utilizzare un _iddoc_id = newbucket fornito.Save ({'_ ID': 'Key4', 'Type': ' Articolo ',' Value ':' JSON TEST ',' $ FLAGS ': 25}) Stampa DOC_ID +' '+ STR (newbucket ) Design = {"_id": "_Design / Test", "Lingua": "JavaScript", "Views": {"Tutto": {"Mappa": '' 'Funzione (DOC) {\ N Emit (Doc, Null); \ n}' ''},},} # Salva un disegno Document # In questo momento con No _REV, possiamo solo creare, non possiamo aggiornare: DOC_ID = NEWBUCKET.Save (Design) tranne: DOC_ID = "_Design / Test" righe = newbucket.View ("_ Design / Test / _view / Tutto ") Per la riga in righe: stampa reawrunning TestSrequirements: - Easy_Install Nose- PIP Installa Nose-TestConfigwe Adesso usando il naso per eseguire i nostri test. C'è una prova fornita.ini.Template che è possibile personalizzare per abbinare l'ambiente installato. Copia test.ini.template per testare.ini, personalizzare, quindi eseguire il seguente comando: Nosetests --tc-file = Test.Iniadding Le informazioni sulla copertura sono facili come installare la copertura e eseguendo i Nosetest con queste impostazioni: Nosetests --tc- File = Test.INI --With-Copertura - Cover --Cover-Package = CouchBase --Cover-HTMLThis emetterà i report di copertura nella homepage della directory "coperchio".


CouchBase-Python. Software correlato