Hello Dominic, What you are trying to do is probably table reflection. You may have a look at : http://www.sqlalchemy.org/docs/05/metadata.html#reflecting-tables
Y.Chaouche --- On Tue, 8/17/10, Dominic LoBue <[email protected]> wrote: > From: Dominic LoBue <[email protected]> > Subject: [elixir] Crash during create_all on fk_colnames.append(col.key) > To: "SQLElixir" <[email protected]> > Date: Tuesday, August 17, 2010, 1:00 AM > Hello, > > Background: > I am using Elixir with a large legacy db. The db has just > about every > type of relation you can think of, and to make matters > worse there are > no FK constraints. The db sql definition can be found > here: > http://gist.github.com/528808 > > Thinking myself clever, I wrote a little sql parser that > generates the > elixir entity classes, all fields, as well as > relationships. The > relationship data I compiled manually, and can be found at > the > following url: http://gist.github.com/528830 > > The format of the relationship data is as follows: > table > fk_column_name related_table.key > fk_column_name related_table.key > > The resulting code can be found here: http://gist.github.com/528811 > > The problem: > When I run setup_all(), I get the following traceback: > Traceback (most recent call last): > File "models.elixir.py", line 1362, in > <module> > setup_all() > File > "/usr/lib64/python2.6/site-packages/elixir/__init__.py", > line > 94, in setup_all > setup_entities(entities) > File > "/usr/lib64/python2.6/site-packages/elixir/entity.py", line > 951, in setup_entities > method() > File > "/usr/lib64/python2.6/site-packages/elixir/entity.py", line > 240, in setup_relkeys > self.call_builders('create_non_pk_cols') > File > "/usr/lib64/python2.6/site-packages/elixir/entity.py", line > 481, in call_builders > getattr(builder, what)() > File > "/usr/lib64/python2.6/site-packages/elixir/relationships.py", > line 451, in create_non_pk_cols > self.create_keys(False) > File > "/usr/lib64/python2.6/site-packages/elixir/relationships.py", > line 721, in create_keys > fk_colnames.append(col.key) > AttributeError: 'NoneType' object has no attribute 'key' > > > Which is entirely unhelpful is determining where the > problem in my > code is :(. > > A google search of the method that's throwing the > exception, or of the > exception that isn't being caught turns up nothing > relevant. > > Help? > > Thanks in advance! > > Dominic > > -- > 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. > > -- 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.
