Hello everyone,

Thanks for the help so far, it has helped me to be very productive
with my current project. Now, for my current issue:

I am a little bit confused by the 'thread-localness' behavior and how
it relates to the Entity tables and DB connection ( http://tinyurl.com/26gjc3
). My desire is to define files like Model.py in the tutorial which
will have all my Entity subclasses and then import them as needed.

Below I have an example of what I am trying to do, which doesn't seem
to be working because the DB is not being created. Basically I have a
script, which is more complicated that below, with several functions.
Some of these functions process the source data and populate the
database.

Thanks!

-------Model.py:

__all__ = ['Movie','Genre','metadata','objectstore']

class Movie(Entity):
    with_fields(
        title = Field(Unicode(30)),
        year = Field(Integer),
        description = Field(Unicode)
    )
    belongs_to('genre', of_kind='Genre')

class Genre(Entity):
    with_fields(
        name = Field(Unicode(15))
    )
    has_many('movies', of_kind='Movie')

-------Script.py:
from Model import *

def process_and_populate():
    # Is it necessary to add a
    # metadata.connect('sqlite://name.db') here?
    Movie(name='foo',year=2008,genre=Genre(name='bar'))

def main():
    metadata.connect('sqlite://name.db')
    metadata.create_all()
    process_and_populate()

if __name__ == '__main__':
    main()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to