🐳 Mongo DB driver (Python).
Project description
metadata-driver-mongodb
🐳 Mongo DB driver for MetadataDB (Python). nevermined.io
Table of Contents
Features
MongoDB driver to connect implementing MetatadaDB.
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
[metadatadb]
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:
metadatadb = MetadataDb(conf)
metadatadb.write({"value": "test"}, id)
Environment variables
When you want to instantiate an Metadatadb 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:
-
price
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:{"price":[0,10]}
It is transformed to:
{"service.metadata.base.price":{"$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"]}
Testing
Automatic tests are setup via Github actions. 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 2020 Keyko GmbH
This product includes software developed at
BigchainDB GmbH and Ocean Protocol (https://www.oceanprotocol.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.
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 nevermined-metadata-driver-mongodb-0.1.0.tar.gz
.
File metadata
- Download URL: nevermined-metadata-driver-mongodb-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d555ab9c237501517566ec6243b37387906c61f39b2c248936f00e94ac2ebbd8 |
|
MD5 | 48b36a23d952cdac529b952a4a042bec |
|
BLAKE2b-256 | 62e39c754d561241273cb5effb3f0cb6ef4db8f4e8fd4cccc6a3b69c9ef50fe3 |
File details
Details for the file nevermined_metadata_driver_mongodb-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: nevermined_metadata_driver_mongodb-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 188740fa74dcf46ab9ed0e94fe38734d6513a584e8152d3ff1216f501b7b5445 |
|
MD5 | 38313cc61547cb0d7df0a18400aef224 |
|
BLAKE2b-256 | 4e37d41b2878a7b156cdf9a1824686a5a3cbf67e412901cf12a3a4be8200a3bc |