A frequent task I run into at work is writing scripts against pre-existing databases. Sometimes I'm connecting to Oracle, other times it might be MySql or even sql server.
What I would like is a tool which would reverse-engineer the database's tables and foreign keys and allow me to write OO-style scripts against the database. This could be in any language really, but python or ruby would be preferred.
For example - this is my ideal ruby script: (assuming the manager and employee tables already exist with foreign keys)
DB = Database.connect(connect_string)
DB.managers.each do |manager|
puts manager.name
manager.employees.each do |employee|
puts employee.name
end
end
Does this type of library exist? If so, it would save me so much time!
Edit - the main feature I would like is for it to automatically discover foreign key associations from the database metadata without explicitly mapping them - I have tried ActiveRecord, SQLAlchemy, Sequel, and DataMapper, and from what I can tell, none of them can do this.