🐳 Mongo DB BigchainDB driver (Python).
Project description
oceandb-mongodb-driver
🐳 Mongo DB driver for OceanDB (Python). oceanprotocol.com
Table of Contents
Features
MongoDB driver to connect implementing OceanDB.
Prerequisites
You should have running a mongo instance.
Quickstart
First of all we have to specify where is allocated our config. To do that we have to pass the following argument:
--config=/path/of/my/config
If you do not provide a configuration path, by default the config is expected in the config folder.
In the configuration we are going to specify the following parameters to
[oceandb]
module=mongodb # You can use one the plugins already created. Currently we have mongodb and bigchaindb.
module.path= # You can specify the location of your custom plugin.
db.hostname=localhost # Address of your MongoDB.
db.port=27017 # Port of your Mongodb.
db.ssl=True # If True, connections will be made using HTTPS, else using HTTP
db.verify_certs=False # If True, CA certificate will be verified
db.ca_cert_path= # If verifyCerts is True, then path to the CA cert should be provided here
db.client_key= # If db server needs client verification, then provide path to your client key
db.client_cert_path= # If db server needs client verification, then provide path to your client certificate
db.username=user # If you are using authentication, mongodb username.
db.password=password # If you are using authentication, mongodb password.
db.name=test # Mongodb database name
db.collection=col # Mongodb collection name
Once you have defined this the only thing that you have to do it is use it:
oceandb = OceanDb(conf)
oceandb.write({"value": "test"}, id)
Environment variables
When you want to instantiate an Oceandb plugin you can provide the next environment variables:
- $CONFIG_PATH
- $MODULE
- $DB_HOSTNAME
- $DB_PORT
- $DB_NAME
- $DB_COLLECTION
- $DB_USERNAME
- $DB_PASSWORD
Queries
Currently we are supporting a list of queries predefined in order to improve the search:
All this queries present a common format:
query:{"name":[args]}
This queries are the following:
-
cost
Could receive one or two parameters. If you only pass one assumes that your query is going to start from 0 to your value.
Next query:
query:{"cost":[0,10]}
It is transformed to:
{"service.attributes.main.cost":{"$gt": 0, "$lt": 10}}
-
license
It is going to retrieve all the documents with license that you are passing in the parameters, if you do not pass any value retrieve all.
{"license":["Public domain", "CC-YB"]}
-
type
It is going to check that the following service types are included in the ddo.
{"type":["Access", "Metadata"]}
-
sample
Check that the metadata include a sample that contains a link of type sample. Do not take parameters.
{"sample":[]}
-
categories
Retrieve all the values that contain one of the specifies categories.
{"categories":["weather", "meteorology"]}
-
created
Retrieve all the values that has been created after a specified date. The parameters available are 'today', 'lastWeek', 'lastMonth', 'lastYear'. If you pass more than one take the bigger interval. If you do not pass any parameter retrieve everything.
{"created":["today"]}
-
updatedFrequency
Retrieve all the values that contain one of the specifies updated frecuencies.
{"updatedFrequency":["monthly"]}
-
text
Retrieve all the values that match with the text sent.
{"text":["weather"]}
Code style
The information about code style in python is documented in this two links python-developer-guide and python-style-guide.
Testing
Automatic tests are setup via Travis, executing tox
.
Our test use pytest framework.
New Version
The bumpversion.sh
script helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.
License
Copyright 2018 Ocean Protocol Foundation Ltd.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file oceandb-mongodb-driver-0.2.2.tar.gz
.
File metadata
- Download URL: oceandb-mongodb-driver-0.2.2.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a3fd8790ee3ab9e7146ddbe47c626aac8b0023bbc52b0d5586767e2acc3681f |
|
MD5 | 47740f0510f8f9c04d5aed91ffc0c9d4 |
|
BLAKE2b-256 | b79d28bc8f9882b0dcd2bfe19abb08b27e158cb9276a78d292aff6fd15f3cdd7 |
File details
Details for the file oceandb_mongodb_driver-0.2.2-py2.py3-none-any.whl
.
File metadata
- Download URL: oceandb_mongodb_driver-0.2.2-py2.py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7149c88d5d276d790092dc9e0270678b1cd97944c554eda071586d74f9ff8f |
|
MD5 | 9e6431a355a0544812f113a82fd35a5b |
|
BLAKE2b-256 | 7c43a864909bc76edb04dd783c1347dc8c7de6e8fe517ecfae4afce5b75aaee9 |