5 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Default data and tab...| From | Sent On | Attachments |
|---|---|---|
| simpsomboy | 21 Dec 2007 06:48 | |
| Michael Bayer | 21 Dec 2007 07:36 | |
| Alexandre da Silva | 21 Dec 2007 08:09 | |
| Michael Bayer | 21 Dec 2007 08:27 | |
| Alexandre da Silva | 21 Dec 2007 08:44 |
| Subject: | [sqlalchemy] Re: Default data and table related database objects![]() |
|---|---|
| From: | Alexandre da Silva (simp...@gmail.com) |
| Date: | 12/21/2007 08:09:22 AM |
| List: | com.googlegroups.sqlalchemy |
database trigger syntax is pretty database specific so we dont have a generic DDL construct for that right now. you can issue the DDL using a textual execute like engine.execute("CREATE TRIGGER ..."). for inserting of data you usually would use a table.insert() construct.
ok, it helps if I have an "after_create" event on mapper or mapped class, than I will able to create all additional objects related with table at moment I call metadata.create_all()
you've lost me here. I don't see the connection between a trigger in your database and a method on one of your mapped classes.
it would be just a Method like after_create_execute("SOME DATABASE SPECIFIC SQL"), and this method should be called after creation of table, but just on creation... would be usefull have an before_drop_execute("SOME STATEMENT") to make users able to drop these related object in case of automatic database recreation
in the same method after_create_execute() users can put insert statements to insert default data to tables, it can be very usefull in some cases.
you'd have to show me what you mean, I don't understand why you need to scroll through all your classes just to set up triggers in your schema. The schema exists independently of any ORM configuration which uses that schema.
if the feature above is not ready, I will put a staticmethod on each mapped class to define my default data and related objects, and will call it for each mapped class.
the methods can contain something like this:
def get_trigger_metadata(): return "CREATE OR REPLACE TRIGGER...."
def initialize_table(): return "INSERT INTO TABLE_NAME VALUES (1,"Lorem Ipsun","foo","bar")"
All this to setup initial additional objects to database i.e. on application setup
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




