How to use mongodrdrl to extract a MongoDB collection schema

22 September,2020 by Jack Vamvas

mongodrdl : what is it ? It is a tool  packaged with MongoDB BI Connector. It has a number of functions to assist is mapping and manipulating schemas. 

How can I use mongodrdl? This is an example of a mongodrdl command line request. In this example the mongodrdl command line tool samples the namespaces of the database and collection specified. For more options check the official MongoDB BI Connector documentation

 

mongodrdl sample --host "myserver" --port 27017 --authenticationDatabase admin --username myAdmin --password myPw1  --db db1 --collection mycollection --out myCollection.drdl

 

This is a snippet from the file output

schema:
- db: myDB
tables:
- table: MyTable
collection: MyTable
pipeline: []
columns:
- Name: _id
MongoType: bson.ObjectId
SqlName: _id
SqlType: objectid
- Name: _class
MongoType: string
SqlName: _class
SqlType: varchar
- Name: dateReceived
MongoType: date
SqlName: dateReceived
SqlType: timestamp ........

 

One of the classic mistakes when it comes to extracting data from MongoDB using BI Connector , is having arbitrary field names. MongoDB is schema-free, but you still need to think about schema and understand  the data needs.That way you are able to shape the data accordingly. MongoDB offers different techniques including Aggregation Pipelines & Views

For example - if you are extracting data using the BI Connector - you may get an error such as : Unknown column.   This could be caused by different reasons but one of the typical reasons is the disparity between documents. i.e a document within the collection is inconsistent. 

 

Read more on BI Connector

How to unlock the secrets of MongoDB BI Connector

How to fix mongo odbc 1.1 access denied for user in Challenge and Response

 

 

 

 

 

 


Author: Jack Vamvas (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to use mongodrdrl to extract a MongoDB collection schema


dba-ninja.com