1

--- UPDATED to be more clear ---

I have quite the task ahead of me, and I am hoping Alembic and SQLAlchemy can do what I need.

I want to develop a desktop application that helps migrate data from one SQLite database to a completely different model and back again. So migrations right? That’s all well and good, but I need to ensure if I haven’t modeled a specific column/table, that it’s ported properly to a table that will be read later to reconstruct the database.

Example:

DB 1:
Table names
    ID
    First Name
    Last Name
Table address
    Street 1
    Street 2
    City
    State

DB2:
Table givenName
    ID
    name
Table Surname
    ID
    Name

Say with alembic I have mapped the following:

DB1 names.firstname => DB2 givenName.name
DB1 names.lastname => DB2 surname.name

But say I want to use a migration to port DB1 to DB2, store the unknown data somewhere, and then reconstruct it properly when I go from DB2 -> DB1.

So how I’d envision this is a joiner table of sorts.

DB2
Table Joiner
    table_name
    column_name
    data

The thing is I want this all to be completely dynamic so no piece of information is ever lost.

Now let's add an extra complexity, and I want to construct a generator of sorts so I can simply pass down new XML/JSON declarations. This would define the mappings, and any calls to translators already based in the code (date conversions, etc).

For an example of two database formats that need to be migrated from one to the other see https://cloudup.com/cYzP2lCQjbo

My question is if this is even possible or conceivable with SQLAlchemy and Alembic. How feasible is this? Any thoughts?

Dovy
  • 1,278
  • 10
  • 19
  • 1
    Might be better if you gave us some examples of data. This is way too abstract. Not to mention that SO generally promotes posting code too. Have any?. It's also unclear what the diff is between master and sqlite here. Also, to be honest this seems like big chunka reqs to be pushing thru as 1 question, very open ended. – JL Peyret May 13 '16 at 05:15
  • Just looking at a high level concept if SQLAlchemy could be used as a migration tool in this way before I go down a rabbit hole. ;) – Dovy May 13 '16 at 05:27

0 Answers0