I am rewriting a big codebase that has to deal with an overly
complicated database.  So one thing which I found very useful for
testing purposes is to replicate only the tables and columns that I
actually need and load them in a memory database to play around with
things.

So for example I have data in this format

data = {
     'table': [(1, 'first'), (2, 'second')],
     'second_table': [],
}

and I populate with 

def populate_data(meta, data=None):
    """Add all the data to the generated tables
    """
    # easy way to add more data to the database
    data = data or DATA
    for table_name, val_list in list(data.items()):
        tbl = Table(table_name, meta)
        for row in val_list:
            tbl.insert().values(row).execute()


But the problem is that the field definition is detached from the
data, and it's a bit confusing now to add more fields.


I thought about strings in CSV format, as

"""
COL1      COL2  COL3
f1        f2    f3
s1        s2    s3
"""

but again the field definition is separate...

Any suggestion about how to make it easier and nicer?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/LPMGKr-pZUEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to