-1

I'm working on a project where I need to migrate from Postgres to MongoDB. The issue is, I cannot save the entire Postgres database to memory. Also, unlike approaches taken here or here, this is not a one-time migration, so I can't copy the entire contents of the Postgres database as text on disk every time data is transferred between the databases.

I was wondering if there was some way to "stream" data, row by row, from Postgres into MongoDB--realy, frompsycopg2 to pymongo.

edit: I suppose I should make the question more specific; I'm asking whether there exists a python library that can stream data between SQL/NoSQL databases, preferably one that works well with psycopg2 and pymongo.

edit2 For those who plan on down-voting, could you leave a comment explaining why? I thought it was a pretty legitimate question.

3
  • 1
    Have you considered using the MongoDB FDW to push data from PostgreSQL to MongoDB? Commented Dec 21, 2018 at 20:33
  • First time I've heard of it, thanks! Although I don't believe I have access to install new packages on the mongo server. I'll definitely look into that though. Commented Dec 21, 2018 at 20:54
  • 1
    You'd install it on the PostgreSQL server, hook up MongoDB collections as foreign tables, and then you could say things like insert into some_mongo_collection (...) select ... from postgresql_table where .... I haven't used it but worth a look. Commented Dec 21, 2018 at 20:56

1 Answer 1

3

To anyone else looking for a solution, I found a python library that might help. This Stack Overflow post asked a similar question to mine, but the author was looking for node.js or java libraries for migration from Postgres to Mongo. However, one of the respondents linked to this python library: pg2mongo: A hassle-free postresql to mongo migration framework.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.