[sqlalchemy] Re: sqlalchemy introspection How?

2007-05-04 Thread Michael Bayer


On May 4, 2007, at 4:08 PM, johnny wrote:


 theres another extension called SqlSoup that does what I think youre
 asking for.  creates the classes on the fly for each table which it
 also reflects on the fly.

 http://www.sqlalchemy.org/trac/wiki/SqlSoup

 This is what I need.

 I have one more question.  Lets say I have a method that updates the
 table and uses SqlSoup to create mappers on the fly.
 That method will be called repeatedly many times in the application.
 That means SqlSoup will introspect the db on every call.

no, just once per table per SqlSoup instance, which you store at the  
module level so its initialized once per application.  the  
performance hit is generally negligible.

 This is bad
 for performance.  I just want to introspect once and save the file on
 disk, so I can import it.

then we go back to the beginning, where you use a declarative  
approach and lay out your Table objects explicitly.  the Metadata  
associated with those tables you pass to an SqlSoup instance.   We  
dont have a print out the tables from a Table feature right now but  
you can get a large part of the way there using repr().

but since you'd have the Table objects laid out anyway, you could use  
explicit mappers and/or an activerecord pattern like Elixir as well.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: sqlalchemy introspection How?

2007-05-03 Thread Michael Bayer


On Apr 28, 2007, at 12:00 PM, johnny wrote:


 What I was trying to get was, there isn't a python command line
 option, that will create Object Mapper Classes for the tables,  so I
 can import them within my applications.  I guess, I have to code these
 every time I need to use a certain table like this:

 metadata = BoundMetaData('dburi')
 user_table = table('user', metadata, autoload=True)
 class User(object):
 pass
 mapper(User, user_table)

 Thank you.

theres another extension called SqlSoup that does what I think youre  
asking for.  creates the classes on the fly for each table which it  
also reflects on the fly.

http://www.sqlalchemy.org/trac/wiki/SqlSoup





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-28 Thread Andreas Jung



--On 27. April 2007 12:57:06 -0700 johnny [EMAIL PROTECTED] wrote:



Does this create a Object Mappers for those tables, so I can do the
following:

Lets say I have a table called user with columns user_name and
password.

ed = User()
ed.user_name = 'Ed'
ed.password = 'edspassword'


You might read the fine SQLAlchemy tutorial first and learn about
mapper classes. sqlalchemy.org - documentation-tutorial.

-aj

pgp1pZXteSEtn.pgp
Description: PGP signature


[sqlalchemy] Re: sqlalchemy introspection How?

2007-04-28 Thread Andreas Jung



--On 28. April 2007 09:00:36 -0700 johnny [EMAIL PROTECTED] wrote:



What I was trying to get was, there isn't a python command line
option, that will create Object Mapper Classes for the tables,


What should that be?


so I
can import them within my applications.  I guess, I have to code these
every time I need to use a certain table like this:

metadata = BoundMetaData('dburi')
user_table = table('user', metadata, autoload=True)
class User(object):
pass
mapper(User, user_table)




huh You can of course write a convenience method to what ever
you like. In addition look at my module z3c.sqlalchemy.

-aj

pgpePCM3O94Kk.pgp
Description: PGP signature