On Thu, Feb 14, 2019 at 1:16 PM Harry wrote:
>
> Hello SQLAlchemy friends, I'm struggling to get sqlalchemy to do what I want.
>
> I'd like to use "classical mappings" so that my business objects are free
> from any direct dependency on sqlalchemy.
note there is a longer term plan to do away wi
PS there's also an SO post if anyone likes those:
https://stackoverflow.com/questions/54649518/sqlalchemy-classical-mapper-custom-data-type-dict-from-columns
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an
Hello SQLAlchemy friends, I'm struggling to get sqlalchemy to do what I
want.
I'd like to use "classical mappings" so that my business objects are free
from any direct dependency on sqlalchemy.
I'm representing two different objects that are very similar: customer
orders and warehouse stock.
Simon, thank you for your kind help.
working excerpt:
Base = declarative_base()
engine = create_engine(app.config.get('SQLALCHEMY_DATABASE_URI'))
metadata = MetaData(bind=engine)
Base.metadata = metadata
# load tables
metadata.reflect(autoload=True)
# load view, as standard reflection ignores v
There are a few different points to make here:
1. SQLAlchemy requires mapped classes to have a primary key defined.
This is because an instance of the mapped class corresponds to a row
in the database. In order to make changes to that row (UPDATE, DELETE
etc.), SQLAlchemy needs to be able to targe
i fiddled around with this. here are some interessting perceptions.
defining the primary_key manually yields this, which is totally irrational
to me. the missing view that i am after is already defined somewhere?
p...
>>> my_view = Table("web_view", metadata, Column("NODE_ID", Integer,
pri