Re: [TML] Python, SqlAlchemy expertise
Christopher Sean Hilton 30 Mar 2015 02:40 UTC
A while ago I was looking for some help with a Traveller System
Generator that I'm working on. To refresh, the system is built with
python against SqlAlchemy as the ORM/data layer. I disappeared while I
played with the Python Debugger. The issue I was having was with
SqlAlchemy 0.9.8 and the automap extension. I was having an issue with
how automap reflects table relationships. Longer explanation
follows.[1] To fix the issue I bit the bullet, switched to
SqlAlchemy's declarative, and wrote a full SqlAlchemy description of
the database. I just wanted to report some status to those people who
offered some help. This code builds the entire schema and then populates
three values into the orbital_body_type table:
http://pastebin.com/kazJ2b45
The code in pastebin works against both SqlAlchemy 0.9.8 and 0.7.x. My
next step will be to take the relationship code here and see if it
fixes the automap issue I was having. Please feel free to followup to
me off the list on this. I'm moving things forward finally.
--
Chris
[1] At length, my hope was to use automap and reflection to write as
little python describing the data as possible. The issue is that my
"OrbitalBody" has a complex relationship to the "Star" table and
automap doesn't built it correctly. The problem is that automap want's
to add "OrbitalBody.Star". Then, when I set OrbitalBody.PrimaryStar,
that also sets OrbitalBody.CompanionStar. This violates a key
constraint in the database.
--
__o "All I was trying to do was get home from work."
_`\<,_ -Rosa Parks
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
Christopher Sean Hilton [chris/at/vindaloo/dot/com]