Skip to main content

banner

metadata-driver-mongodb

🐳 Mongo DB driver for MetadataDB (Python). nevermined.io

PyPI Python package


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.

Metadata

Release files for nevermined-metadata-driver-mongodb 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nevermined-metadata-driver-mongodb 0.1.0
File Size Uploaded Provenance
nevermined-metadata-driver-mongodb-0.1.0.tar.gz 16.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nevermined-metadata-driver-mongodb 0.1.0
File Interpreter ABI Platform
nevermined_metadata_driver_mongodb-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 28.5 kB

Release files / nevermined-metadata-driver-mongodb-0.1.0.tar.gz

Download URL nevermined-metadata-driver-mongodb-0.1.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d555ab9c237501517566ec6243b37387906c61f39b2c248936f00e94ac2ebbd8
BLAKE2b-256 checksum
How to use checksums
62e39c754d561241273cb5effb3f0cb6ef4db8f4e8fd4cccc6a3b69c9ef50fe3
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / nevermined_metadata_driver_mongodb-0.1.0-py2.py3-none-any.whl

Download URL nevermined_metadata_driver_mongodb-0.1.0-py2.py3-none-any.whl
Size 12.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
188740fa74dcf46ab9ed0e94fe38734d6513a584e8152d3ff1216f501b7b5445
BLAKE2b-256 checksum
How to use checksums
4e37d41b2878a7b156cdf9a1824686a5a3cbf67e412901cf12a3a4be8200a3bc
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for nevermined-metadata-driver-mongodb 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page