On Apr 19, 2013, at 11:13 AM, Philipp Kraus <[email protected]> wrote:
> Thanks for your great explanation, I think I would help, but I must describe > some additional information in my using: > I try to create a proof-of-concept for a database builder eg > http://www.liquibase.org/ > I use for my project SCons ( http://www.scons.org ) like a build toolkit and > would like to add a database builder, that can create and update any database > So I would describe the database structure like a Python dict. I don't want > implementate all database specific parts, so I would like to use SQLAlchemy, > in my case something like: database description => SCons builder => > SQLAlchemy => database driver => database > > So the creating / update process should be in a transaction, because if the > builder process fails all changes should be restored. SCons itself uses > a more functional structure, so I generate from the input of the builder the > sqlalchemy.Table objects and run these objects with the metadata. I'm testing > the > codes with mySQL and Postgres. So at the moment I'm learning the structure of > SQLAlchemy and try to create the description of the database first. > At the moment I don't know which way is the best to create the database > structure, the best is, that the user does not see any SQL specific parts, > so would you create Python classes for the databases (ORM style) and push > them to SQLAlchemy for creating the structure? > How can you updates these tables eg a field type is changed? if your application thinks in terms of tables I might just use straight Table objects. The Table and related structures can handle new things being added to them, like columns and constraints, but aren't suitable for changes that involve replacing or removing columns and constraints. So if you have a system dealing with things in terms of descriptions, you might want to just recreate a new Table structure each time a change needs to be accommodated. But this also doesn't have any bearing on emitting alterations to the database itself. For that, you'd need to emit the appropriate ALTER statements. Two products that can help with this are Alembic and SQLAlchemy-Migrate, though they are both tailored towards the specific case of generating a series of migration files. Alembic is my own tool and has a more open-ended API. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
