Connecting to ProvenDB
In Creating a ProvenDB service we showed you how to create a new ProvenDB service. You should now have a ProvenDB URI string and a username/password combination. You'll now use these to connect to your ProvenDB service.
As a reminder, your ProvenDB URI is shown in your service dashboard. This is the string you use to connect to your ProvenDB service from the mongo shell or from MongoDB drivers:
In Creating a ProvenDB service we used myUserName
as our username, myPassword
as the password (not recommended) and were given a URI of mongodb://${USERNAME}:${PASSWORD}@myprovendb.provendb.io/dev_myprovendb?ssl=true
. We'll use these in the following examples.
The URI you are given includes ${USERNAME}
and ${PASSWORD}
as placeholders for the username and passwords that you chose. If we substitute our actual username and password, then our URI would be:
mongodb://myUserName:[email protected]/dev_myprovendb?ssl=true
Connecting to ProvenDB using the MongoDB Shell
To connect using the MongoDB shell simply type the mongo command, followed by your URI:
Of course, your URI will be different - you should substitute the username/password you chose when creating the service, and use the URI given to you when the service creation was complete.
Connecting to ProvenDB from the ProvenDB Shell helper
If you install the ProvenDB shell helper ProvenDB Shell helper , then you connect by typing ProvenDBShell.sh (Mac or Unix) or ProvenDBShell (Windows), followed by your URI:
Connecting to ProvenDB from programming languages
The procedure for connecting to provenDB from development environments such as NodeJS or Java is the same as connecting to any mongoDB database. For instance, the following NodeJ commands connect to the provenDB server created above and report the current version number:
const MongoClient = require('mongodb').MongoClient;
const provendbUri = 'mongodb://myUserName:[email protected]/dev_myprovendb?ssl=true';
async function main() {
const mongoclient = await MongoClient.connect(provendbUri, {
'useNewUrlParser': true
});
const provendb = mongoclient.db();
const currentVersion = await provendb.command({getVersion: 1});
console.log(currentVersion);
process.exit(0);
}
main();
This code snippet should print something like this:
{ ok: 1,
response: "The version is set to: 'current'",
version: 1,
status: 'current' }
Consult the ProvenDB Developers guide and MongoDB documentation to find out how to connect from other MongoDB drivers.
Connecting from dbKoda
https://www.dbkoda.com/ is a MongoDB GUI tool developed by the developers of ProvenDB that is known to work with ProvenDB. To connect using dbKoda, select "Create a new Profile" from the dbKoda home screen:
Then paste your ProvenDB URI into the URI field at the bottom of the profile configuration screen:
Click the green CONNECT button to connect to ProvenDB
Updated almost 5 years ago