All - I'm working on a simple migration script for Elixir based databases, and I've run into some issues. While I was creating a demo script to illustrate these issues so I could post to this group, I ran into another problem that I think may be related. Below is a simple script that creates some entries in an Elixir/sqlite database, dumps them into a RAM structure, and then attempts to load them into a different database. In this sample script, both databases use the same database schema (version).
Also, the script can be viewed/downloaded here: http://bitbucket.org/dls/elixir_dump_test/src/tip/dumpTest.py The code is: #**************************************************************************** from elixir import * dict= {} class User(Entity): using_options(tablename='User') name = Field(String, unique=True) expenses = OneToMany('Expense') def __repr__(self): return "<User ('%s', '%s')>" % (self.id, self.name) class Expense(Entity): using_options(tablename='Expense') user = ManyToOne('User') amount = Field(Float) def __repr__(self): return "<Expense ('%s', '%s')>" % (self.id, self.amount) # connect connString = 'sqlite:///' + 'dumpTest.db' metadata.bind = connString setup_all() create_all() # create some data u1 = User(name='John Doe') u2 = User(name='Jane Doe') e1 = Expense(user=u1, amount='15.01') e2 = Expense(user=u2, amount='50.25') session.commit() # dump to dict dict['User'] = User.query.all() print dict['User'] dict['Expense'] = Expense.query.all() print dict['Expense'] # close session session.close() cleanup_all() # connect to db #2 connString = 'sqlite:///' + 'dumpTest2.db' metadata.bind = connString setup_all() create_all() for i in dict['User']: u = User() u.name = i.name # works u.expenses = i.expenses # does not work for i in dict['Expense']: e = Expense() e.amount = i.amount # works e.user = i.user # does not work session.close() cleanup_all() and the error, triggered on line 52 (marked above) is: sqlalchemy.orm.exc.UnmappedInstanceError: Class '__main__.User' is not mapped What am I missing here? I'm new to both Elixir and database work so I'm flying a bit blind. -- 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.
