Heston wrote:
> [SNIP]
> 
> Above you talk about a global module in the application which 
> creates the
> Base and metadata, but I don't understand how these can then 
> be accessed by
> other classes around the application?
> 
> Do you have any good sample code or a link to a decent 
> tutorial? Seems all I
> can find are examples which are based on the idea that all 
> the classes are
> defined in the same module, which isn't practical.
> 

Hi Heston,

This is really a plain python question rather than an SQLAlchemy
question. You might find this section of the python tutorial useful:

http://docs.python.org/dev/tutorial/modules.html

But basically, if you put the following code in a module called
'base.py':

#---------------------------------------------------------
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import MetaData

meta = MetaData()
Base = declarative_base(metadata=meta)
#---------------------------------------------------------

Then in your other modules you can write:

#---------------------------------------------------------
import base

class Post(base.Base):
    __tablename__ = 'post'

    # etc.

#---------------------------------------------------------

Hope that helps,

Simon

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to