[sqlalchemy] How to generate view columns in mapped class with async postgresql

2022-12-14 Thread 'dcs3spp' via sqlalchemy
Hi, I am using alembic to apply a migration for a postgresql view using an *async *engine. I can see this successfully applied in the database. I have the following declarative mapped class to the view, defined as: *class MailingListView(Base): """View for mailing labels.After met

[sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-07 Thread 'dcs3spp' via sqlalchemy
Ok cheers Mike. So I detect at collection level and then throw Exception if already a member. So I might get better performance by changing collection to a set and checking for membership before adding via the event listener. Ok, thanks for your help and suggestions. Much appreciated :) Cheers

[sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-07 Thread 'dcs3spp' via sqlalchemy
Hi Mike, Thanks for getting back to me and suggesting viable workarounds :) Will probably go with the event listener approach. Is it worthwhile submitting this as an issue on bitbucket? Cheers Simon On Tuesday, 6 December 2016 14:36:15 UTC, dcs3spp wrote: > > Hi, > > > I am running SQLAlchemy

Re: [sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-07 Thread 'dcs3spp' via sqlalchemy
"some_unique_thing", name="uq_1"), > ) > > e = create_engine("postgresql://scott:tiger@localhost/test", echo=True) > Base.metadata.drop_all(e) > Base.metadata.create_all(e) > > s = Session(e) > > a1 = A(bs=[B(some_unique_thing=1)]) > s

Re: [sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-06 Thread 'dcs3spp' via sqlalchemy
> Base.metadata.drop_all(e) > Base.metadata.create_all(e) > > s = Session(e) > > a1 = A(bs=[B(some_unique_thing=1)]) > s.add(a1) > s.commit() > > a1.bs.append(B(some_unique_thing=1)) > s.commit() > > > > > > On 12/06/2016 12:10 PM, 'dcs3spp'

Re: [sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-06 Thread 'dcs3spp' via sqlalchemy
4760, 'OutcomeID': 4, 'AssignmentID': 1, 'UnitID': 2} 2016-12-06 17:00:33,879 INFO sqlalchemy.engine.base.Engine COMMIT 2016-12-06 17:00:33,879 INFO [sqlalchemy.engine.base.Engine:109][MainThread] COMMIT Test Script complete... On Tuesday, 6 December 2016 16:27:

[sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-06 Thread 'dcs3spp' via sqlalchemy
Hi, Good suggestion by Mike, regarding possibility that problem could be with postgreSQL. Tried inserting duplicate record in association table from within postgreSQL. This correctly raises a duplicate key error. proposed_coursemanagement=> INSERT INTO assignmentoutcome VALUES (1, 1014760, 2,

[sqlalchemy] Re: SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-06 Thread 'dcs3spp' via sqlalchemy
Hi Mike, Thanks for response. I do have the use of the UniqueConstraint in the association table included below. Any other suggestions? assignmentoutcomeallocation = Table('assignmentoutcome', Base.metadata, Column('CourseID', BigInteger, primary_key=True), Column('UnitID', Integer, pr

[sqlalchemy] SQLAlchemy 1.1.4 - How do I get SQLAlchemy to raise an exception when appending a duplicate persistent object that is already mapped in a relationship?

2016-12-06 Thread 'dcs3spp' via sqlalchemy
Hi, I am running SQLAlchemy 1.1.4 connected to postgreSQL 9.6 on OSX Sierra 10.12.1. I am experiencing difficulty getting SQLAlchemy to raise an integrity error when a persistent object is appended to a relationship for which it is already associated with. Is the accepted method to manu