Hi
I'm studying examples of using database in pylons. SQLAlchemy is most
commonly used here. But I don't understand why most of them use explicit
column declaration.
I want to use Postgres database which supports ALTER table statement.
Following those examples if I need to change column name from
character(30) to charcater(50) I will have to do it in my code and then
in pgadmin tool. I would prefer to do it in pgadmin only and my model
applying those changes automatically.
I'm trying to get Elixir's reflection working:
#models/user.py
import pyoner.models as model
class User(Entity):
Entity.table = model.table_user
#models/__init__.py
from pylons.database import session_context
from elixir import metadata
from sqlalchemy import Table, BoundMetaData
engine = session_context.current.bind_to
table_user = Table('user', BoundMetaData(engine), autoload = True)
Here I have simple table with id, username, password. It seems that
reflection works, but User.select() ends up with:
*<class 'sqlalchemy.exceptions.SQLError'>: (ProgrammingError) relation
"pyoner_models_user_user" does not exist 'SELECT
pyoner_models_user_user.id AS pyoner_models_user_user_id \nFROM
pyoner_models_user_user ORDER BY pyoner_models_user_user.id' {}*
I use sqlalchemy 0.3.7, elixir 0.3, pylons o.9.6
And maybe one could provide some arguments why I should explicitly
declare tables in my models? Some pros and cons list?
--
Best regards,
Antipin Aleksei
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---