![]() Template_Field_View.psql CREATE OR REPLACE VIEW quick_bits.template_field_view ASįROM quick_bits.template_field as template_field Template integer REFERENCES quick_bits.Template(id),įield integer PRIMARY KEY REFERENCES quick_bits.Field(id), CREATE TABLE IF NOT EXISTS quick_bits.Template_Field( Out, however I left the relation in Template_Field for illustrative purposes. Templates in them self are not interesting for this obstacle and are thus left Field.psql CREATE TABLE IF NOT EXISTS quick_bits.Field ( ![]() Of the common field type and is never accessed directly but rather through the One such is Template_Field shown below, this is a mere extension In my case we’ve got a base model forįields followed by a couple of related models for specialised instances of I’ve oversimplified the model and view to press on the actual issue and not A problematic domain model – sample code attached One must use the Table() construct to initiate the view, and herein lies theįoundational problem, see table’s in SQLAlchemy requires a primary key to useĪs a hash while views in PostgreSQL can’t. There’s as of this date no way to natively reflect a view in SQLAlchemy. Well here’s the thing, to the best of my knowledge Sometimes it does not fit their model as well. Made to fit most databases moderately well for most common use cases. The core problem comes from SQLAlchemy being an ORM (object relationship mapper) I ran into this problem a while ago, where I had a simple view createdīy joining two tables with a 1:1 relationship in PostgreSQL but SQLAlchemy Hultnér QuickBits Reflect a PostgreSQL view in Python’s SQLAlchemy
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |