All Projects → Maltcommunity → Mongo Connector Postgresql

Maltcommunity / Mongo Connector Postgresql

River from Mongo oplog to postgresql

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Mongo Connector Postgresql

Helicalinsight
Helical Insight software is world’s first Open Source Business Intelligence framework which helps you to make sense out of your data and make well informed decisions.
Stars: ✭ 214 (+723.08%)
Mutual labels:  business-intelligence, mongodb, postgresql
Redash
Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
Stars: ✭ 20,147 (+77388.46%)
Mutual labels:  business-intelligence, postgresql
Gokv
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)
Stars: ✭ 314 (+1107.69%)
Mutual labels:  mongodb, postgresql
Django Dbbackup
Management commands to help backup and restore your project database and media files
Stars: ✭ 471 (+1711.54%)
Mutual labels:  mongodb, postgresql
Waline
A Simple, Safe Comment System inspired by Valine | 一款基于 Valine 衍生的简洁、安全的评论系统
Stars: ✭ 260 (+900%)
Mutual labels:  mongodb, postgresql
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+11680.77%)
Mutual labels:  mongodb, postgresql
Micronaut Microservices Poc
Very simplified insurance sales system made in a microservices architecture using Micronaut
Stars: ✭ 394 (+1415.38%)
Mutual labels:  mongodb, postgresql
Typescript Express Starter
🚀 TypeScript Express Starter
Stars: ✭ 238 (+815.38%)
Mutual labels:  mongodb, postgresql
Backup
Easy full stack backup operations on UNIX-like systems.
Stars: ✭ 4,682 (+17907.69%)
Mutual labels:  mongodb, postgresql
Dev Setup
macOS development environment setup: Easy-to-understand instructions with automated setup scripts for developer tools like Vim, Sublime Text, Bash, iTerm, Python data analysis, Spark, Hadoop MapReduce, AWS, Heroku, JavaScript web development, Android development, common data stores, and dev-based OS X defaults.
Stars: ✭ 5,590 (+21400%)
Mutual labels:  mongodb, postgresql
Blog
Everything about database,business.(Most for PostgreSQL).
Stars: ✭ 6,330 (+24246.15%)
Mutual labels:  mongodb, postgresql
Widestage
Lightweight Open Source Business Intelligence and reporting tool for mongodb, postgresql, Mysql, MS sql, oracle, & google bigQuery allow users create their own reports just dragging and dropping, widestage also has a data governance layer AKA semantic layer
Stars: ✭ 246 (+846.15%)
Mutual labels:  business-intelligence, mongodb
Zxw.framework.netcore
基于EF Core的Code First模式的DotNetCore快速开发框架,其中包括DBContext、IOC组件autofac和AspectCore.Injector、代码生成器(也支持DB First)、基于AspectCore的memcache和Redis缓存组件,以及基于ICanPay的支付库和一些日常用的方法和扩展,比如批量插入、更新、删除以及触发器支持,当然还有demo。欢迎提交各种建议、意见和pr~
Stars: ✭ 691 (+2557.69%)
Mutual labels:  mongodb, postgresql
Yiigo
🔥 Go 轻量级开发通用库 🚀🚀🚀
Stars: ✭ 304 (+1069.23%)
Mutual labels:  mongodb, postgresql
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+14800%)
Mutual labels:  mongodb, postgresql
Shell
Infrastructure Management Shell - Linux
Stars: ✭ 381 (+1365.38%)
Mutual labels:  mongodb, postgresql
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (+665.38%)
Mutual labels:  mongodb, postgresql
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+10792.31%)
Mutual labels:  mongodb, postgresql
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+1815.38%)
Mutual labels:  mongodb, postgresql
Newsblur
NewsBlur is a personal news reader that brings people together to talk about the world. A new sound of an old instrument.
Stars: ✭ 5,862 (+22446.15%)
Mutual labels:  mongodb, postgresql

PROJECT STOPPED AND REPLACED

This project helped us a lot but we encounter several limitations and performance issues we were not confident to fix with the current architecture. Indeed, this project is a plugin above another project and this other project is not supported anymore since more than 1 year. That's why we decided to rewrite the whole process to improve performance, bring some monitoring checks, improve stability. You can find this new tool here : mongo-postgresql-streamer <https://github.com/Maltcommunity/mongo-postgresql-streamer>__

As now, this project won't be supported anymore but you could switch to mongo-postgresql-streamer.


.. image:: https://travis-ci.org/Hopwork/mongo-connector-postgresql.svg?branch=master .. image:: https://coveralls.io/repos/github/Hopwork/mongo-connector-postgresql/badge.svg?branch=master

Continuous Integration <https://travis-ci.org/Hopwork/mongo-connector-postgresql>_ - Code Coverage <https://coveralls.io/github/Hopwork/mongo-connector-postgresql>_

mongo-connector-postgresql is used to make the bridge between PostgreSQL and MongoDB. It acts as a river from MongoDB to PostgreSQL.

This connector is a plugin for Mongo Connector <https://github.com/10gen-labs/mongo-connector/wiki>__. Thanks a lot for their contribution !

DISCLAIMER

Please note: all tools and scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. We disclaim any and all warranties, either express or implied, including but not limited to any warranty of noninfringement, merchantability, and/ or fitness for a particular purpose. We do not warrant that the technology will meet your requirements, that the operation thereof will be uninterrupted or error-free, or that any errors will be corrected. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.

System Overview

mongo-connector-postgresql creates a pipeline from a MongoDB cluster to PostgreSQL. It synchronizes data in MongoDB to the target then tails the MongoDB oplog, keeping up with operations in MongoDB in real-time. It has been tested with Python 2.7 and PostgreSQL 9.5.

All the works of tailing the oplog, performing the initial sync is made by the mongo-connector <https://github.com/10gen-labs/mongo-connector/wiki>__. So the first documentation you should read is on their website.

Getting Started

For some context (in french) : See our blog article <https://medium.com/nerds-malt/business-intelligence-sur-mongodb-de-mongo-%C3%A0-postgresql-%C3%A0-chartio-ddc9e2f561ef/>_

Installation


The easiest way to install mongo-connector and our extension is with:

.. code-block:: bash

    pip install mongo-connector mongo-connector-postgresql

Using this connector

For the configuration of the connector, please check out the mongo-connector documentation <https://github.com/mongodb-labs/mongo-connector/wiki>_ beforehand since only the pg-mongo-connector specifics are written here.

Just call the mongo-connector and specify this plugin with the option -d:

.. code-block:: bash

mongo-connector -t postgresql://localhost -d postgresql_manager -c config.json

The url could follow any of the syntax defined by libpq connection string <http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING>__.

This connector use its own mapping file to determine the fields that should be written in PostgreSQL and their types. This file should be named mappings.json. Here is a sample :

.. code-block:: javascript

{
    "my_mongo_database":{
        "my_mongo_collection":{
            "pk":"id",
            "indices":[
                "UNIQUE INDEX subproperty_idx ON my_postgre_table(subproperty)"
            ],
            "_id":{
                "dest":"id",
                "type":"TEXT"
            },
            "description":{
                "type":"TEXT",
                "index": true,
            },
            "enable":{
                "dest":"enabled",
                "type":"BOOLEAN"
            },
            "myobject.subproperty":{
                "dest":"subproperty",
                "type":"TEXT"
            },
            "propertyWhichMayBeNull": {
                "dest":"property_has_been_provided",
                "type":"_PRESENCE"
            }
        }
    }
}

Please notice the following :

  • The pk field is mandatory and should point to the destination's primary key
  • By default, the dest field is set to the original Mongo field name.
  • If the original document in mongodb has a embedded document, everything is flattened to be inserted in PostgreSQL
  • One can define indices in two different ways : Using the array indices and a SQL definition or autogenerate index by setting the index field to true

The connector also supports arrays of documents. Let say your Mongo database stores the following documents :

.. code-block:: javascript

{
    "posts":{
        "name":"Check out the mongo -> postgres connector",
        "content":"Inspiring blog post",
        "comments":[
            {
                "user":"Elon Musk",
                "comment":"What a revolution !"
            },
            {
                "user":"Kevin P. Ryan",
                "comment":"Nice !"
            }
        ]
    }
}

To allow the connector to map the post objects AND its comments, you should use the following mapping :

.. code-block:: javascript

{
    "my_mongo_database":{
        "posts":{
            "pk":"id",
            "_id":{
                "dest":"id",
                "type":"TEXT"
            },
            "content":{
                "type":"TEXT"
            },
            "comments":{
                "type":"_ARRAY",
                "fk":"post_id"
            }
        },
        "comments":{
            "pk":"id",
            "post_id":{
                "dest":"post_id",
                "type":"TEXT"
            },
            "user":{
                "dest":"user",
                "type":"TEXT"
            },
            "comment":{
                "dest":"comment",
                "type":"TEXT"
            }
        }
    }
}

Please notice the following :

  • The type _ARRAY is used to indicate to the connector that the field is an array
  • The additional field fk is provided to indicate to the connector where to store the root document id. This field is mandatory for an array
  • The comments' mapping declares only the primary key but no mapping exists. The connector will generate the identifier automatically
  • The foreign key must be declared in the comments table so it's created with the schema initialization

Finally, the connector supports arrays of scalar. Let say your Mongo database stores the following documents in the timeline collection :

.. code-block:: javascript

{
	"author": "507f1f77bcf86cd799439011",
	"posts": [{
		"name": "Check out the mongo -> postgres connector",
		"tags": [
			"Awesome",
			"Article",
			"Postgres"
		]
	}]
}

One can use the following mapping :

.. code-block:: javascript

{
	"my_mongo_database": {
		"timeline": {
			"pk": "id",
			"_id": {
				"dest": "id",
				"type": "TEXT"
			},
			"author": {
				"type": "TEXT"
			},
			"posts": {
				"type": "_ARRAY",
				"dest": "timeline_posts",
				"fk": "timeline_id"
			}
		},
		"timeline_posts": {
			"pk": "id",
			"_id": {
				"dest": "id",
				"type": "TEXT"
			},
			"name": {
				"type": "TEXT"
			},
			"tags": {
				"dest": "timeline_posts_tags",
				"type": "_ARRAY_OF_SCALARS",
				"fk": "timeline_post_id",
				"valueField": "tag"
			}
		},
		"timeline_posts_tags": {
			"pk": "id",
			"_id": {
				"dest": "id",
				"type": "TEXT"
			},
			"tag": {
				"type": "TEXT"
			}
		}
	}
}

Contribution / Limitations

We searched for a software like this for quiet a time and we are confident that other people would need it. However, some features/improvements are currently lacking :

  • A better documentation ?
  • Their is no way to map a mongo collection to a differently named postgres table
  • There is virtually no error handling, especially if the mapping is wrong (e.g. missing pk field)
  • Rollbacks are not supported
  • System commands are not supported (e.g. create collection)
  • Only operations on the 'public' schema are allowed
  • Currently, because of our use of the ON CONFLICT directive, only PostgreSQL >= 9.5 can be used

Even if this code is battle tested (we use it in production and fix for bugs every time we see one), it is far from perfect. Indeed, it was written quickly, by Python aware (but still Java specialized) developers in a "proof of concept" perspective. Therefore, one can easily improve the code quality, the test coverage (which is currently 0%), the architecture or write more 'Pythonic' code.

How to publish to Pypi ?

  1. Create you ~/.pypirc with the following model :

    [distutils] index-servers= testpypi pypi

    [testpypi] repository=https://test.pypi.org/legacy/ username=hopwork password=REPLACE_ME

    [pypi] repository=https://upload.pypi.org/legacy/ username=hopwork password=REPLACE_ME

  2. Execute the publish.sh script

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].