Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-27 Thread Stanislav Lobanov
ies_from_join() for ent in entities: # check entity and apply filtering return query Thanks! воскресенье, 9 декабря 2018 г., 19:57:26 UTC+3 пользователь Mike Bayer написал: > > On Sun, Dec 9, 2018 at 11:22 AM Stanislav Lobanov > wrote: > > > >

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-10 Thread Stanislav Lobanov
o override "new_version" method, then the system may start having consistency issues. воскресенье, 9 декабря 2018 г., 19:57:26 UTC+3 пользователь Mike Bayer написал: > > On Sun, Dec 9, 2018 at 11:22 AM Stanislav Lobanov > wrote: > > > > Hello, i have one more questi

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-09 Thread Stanislav Lobanov
cs.sqlalchemy.org/en/latest/orm/examples.html#module-examples.versioned_rows > > since it has this new twist of doing both UPDATE and INSERT, if that's > OK with you > On Fri, Dec 7, 2018 at 1:20 AM Stanislav Lobanov > wrote: > > > > Thank you so much, Mike! > > > > Did

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-07 Thread Stanislav Lobanov
has this new twist of doing both UPDATE and INSERT, if that's > OK with you > On Fri, Dec 7, 2018 at 1:20 AM Stanislav Lobanov > wrote: > > > > Thank you so much, Mike! > > > > Did not tried it yet, but it looks like you nailed it :) I'll check the > s

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-06 Thread Stanislav Lobanov
;child_end" columns to form full > composite FK to child table). > > > > > > When child is updated (effectively UPDATE is converted to INSERT) then > only child table is modified, so there are no cascades to parent, because > parent just targets to the row where

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-06 Thread Stanislav Lobanov
instance.end = dt.datetime(2060, 1, 1) # re-add session.add(instance) Thanks :) четверг, 6 декабря 2018 г., 18:02:48 UTC+3 пользователь Mike Bayer написал: > > On Thu, Dec 6, 2018 at 3:53 AM Stanislav Lobanov > wrote: > > > > Example bu

[sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-06 Thread Stanislav Lobanov
tency, data integrity, data querying must be done by hands, because i did not found a way to provide cascades and correct relationship behaviour without full composite FK. Thanks! вторник, 4 декабря 2018 г., 15:36:42 UTC+3 пользователь Stanislav Lobanov написал: > > Hello. > > I have a t

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-05 Thread Stanislav Lobanov
зователь Mike Bayer написал: > > On Wed, Dec 5, 2018 at 2:42 AM Stanislav Lobanov > wrote: > > > > First of all, thank you for such a detailed answer. Thank you for > sharing your experience and continued support. > > > > Now i understand that using datab

Re: [sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-05 Thread Stanislav Lobanov
Mike Bayer написал: > > On Wed, Dec 5, 2018 at 2:42 AM Stanislav Lobanov > wrote: > > > > First of all, thank you for such a detailed answer. Thank you for > sharing your experience and continued support. > > > > Now i understand that using database views is not th

[sqlalchemy] Re: ORM: read from view but write into separate table

2018-12-04 Thread Stanislav Lobanov
ad english, it is not on my tongue. вторник, 4 декабря 2018 г., 15:36:42 UTC+3 пользователь Stanislav Lobanov написал: > > Hello. > > I have a table with schema: > > name: users > fields: id int, name text, start datetime, end datetime > primary key: id, start, end &g

[sqlalchemy] ORM: read from view but write into separate table

2018-12-04 Thread Stanislav Lobanov
Hello. I have a table with schema: name: users fields: id int, name text, start datetime, end datetime primary key: id, start, end This is kind of a historical table, where each row defines separate "historical version" of an object. There are a single business User entity (model) with

[sqlalchemy] Re: Dynamic sequence name

2018-04-25 Thread Stanislav Lobanov
Thank you very much! It is working now. My mistake was to use @declared_attr to create a unique sequence per mapper, and that was not working of course. среда, 25 апреля 2018 г., 22:04:58 UTC+3 пользователь Stanislav Lobanov написал: > > Hello! > > I have a base model class wit

[sqlalchemy] Dynamic sequence name

2018-04-25 Thread Stanislav Lobanov
Hello! I have a base model class with "id" field, which is primary key and also not nullable. It does not have autoincrement feature, but uses custom sequence manually to assign it's value. There are standard on table / sequence naming: class Base: id = Column(Integer, primary_key=True,

[sqlalchemy] Re: Dynamically change table name to select from for query

2018-03-04 Thread Stanislav Lobanov
Thank you very much, your answer is very detailed as always. I think that this approach may fit to me, because this tables are read-only, because it is kind of datawarehouse. Thanks! суббота, 3 марта 2018 г., 10:45:45 UTC+3 пользователь Stanislav Lobanov написал: > > Hello! >

[sqlalchemy] Dynamically change table name to select from for query

2018-03-02 Thread Stanislav Lobanov
Hello! I have a database with 10 tables with same structure. This structure of a tables are always the same. I want to be able to query this tables using one declarative mapper instead of 10 similar mappers, but to do so i need a way to change table name somehow. Desired code: class

[sqlalchemy] Re: Auto-alias on polymorphic_identity tables

2018-02-12 Thread Stanislav Lobanov
Thank you for your support and contributions, Mike, you are a great person. понедельник, 12 февраля 2018 г., 13:14:24 UTC+3 пользователь Stanislav Lobanov написал: > > Hello, i'm supporting legacy database, and using such models (code > contains examples of my problem, keep reading):

[sqlalchemy] Auto-alias on polymorphic_identity tables

2018-02-12 Thread Stanislav Lobanov
Hello, i'm supporting legacy database, and using such models (code contains examples of my problem, keep reading): class Product: # This table is never used straightforward in queries type = Column(db.Integer) name = Column(db.String) TYPE_GUITARS = 1 TYPE_DRUMS = 2

[sqlalchemy] Re: Implementing historical tables

2018-01-31 Thread Stanislav Lobanov
technical requirements. четверг, 1 февраля 2018 г., 5:35:26 UTC+3 пользователь Jonathan Rogers написал: > > > > On Wednesday, January 31, 2018 at 12:27:12 PM UTC-5, Stanislav Lobanov > wrote: >> >> Hello, i need to create a system, that can store historical versions of >

Re: [sqlalchemy] Implementing historical tables

2018-01-31 Thread Stanislav Lobanov
any of those fit your > specific needs. > > Bests, > Martín > > 1- https://github.com/kvesteri/sqlalchemy-continuum > 2- > http://docs.sqlalchemy.org/en/latest/orm/examples.html?highlight=history#versioning-objects > > On Wed, Jan 31, 2018 at 2:27 PM Stanislav Loba

[sqlalchemy] Implementing historical tables

2018-01-31 Thread Stanislav Lobanov
Hello, i need to create a system, that can store historical versions of objects. Example model looks like: class User(Base): id=Column(Integer) # ForeignKey start=Column(DateTime) end=Column(DateTime) name=Column(String) I have implemented .add_new() and .save() methods on base