most of these questions are more SqlAlchemy oriented, not about pyramid.

the initialize_db stuff is only needed when you're creating a database from 
scratch. many people don't do that.  there are a handful of SqlAlchemy 
oriented projects on PyPi that will build a "declarative" based models.py 
from an existing database.  I've made a few dozen projects with 
pyramid+sqlalchemy, I've only used an initialize_db script once.   This 
sort of stuff is more common in higher level projects like Django and 
Rails, which tend to automate database creation & migrations or are 
designed to minimize/remove developer interactions with the database. 
 pyramid gives you the choice to handle the database yourself if you want.

In SqlAlchemy, "reflection" allows you to create a class out of database 
connection and a table name.  I find this useful for small projects and 
quick fixes, but takes a little bit of overhead and isn't very extensible. 
 Some people don't like the performance on production systems.

Another approach to defining SqlAlchemy models is "declarative", where you 
declare a class and associate it to a table name. 
(http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative.html) 
You're then able to extend the class with various methods and 
relationships.  It's a lot easier to use.  Most people will use the 
"declarative" approach in their models.py folder.

Most people prefer using declarative.  The SqlAlchemy ORM tutorial is 
written using declarative 
(http://docs.sqlalchemy.org/en/latest/orm/tutorial.html)

In terms of "double work" -- initialize_db and migration scripts (using 
alembic) allow you to avoid writing the CREATE/ALTER sql statements.  They 
can generate the necessary statements based on the Python models.  The 
alternative is to write raw sql, optimize your database, and then create 
classes in model.py that map python to the database.  

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to