Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-07-14 Thread Marat Sharafutdinov
=/ On Thursday, June 10, 2021 at 3:57:08 PM UTC+3 Mike Bayer wrote: > > > On Wed, Jun 9, 2021, at 7:21 PM, Marat Sharafutdinov wrote: > > The problem is that currently only the entire codebase can be migrated > from 1.3 to 1.4, even though it can be extremely difficult or too lo

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-09 Thread Marat Sharafutdinov
t;. > > As you've probably seen, SQLAlchemy 1.4 /2.0 includes a very specific > upgrade path with step-by-step instructions at > https://docs.sqlalchemy.org/en/14/changelog/migration_20.html . > > > > On Wed, Jun 9, 2021, at 4:15 PM, Marat Sharafutdinov wrote: > > C

[sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-09 Thread Marat Sharafutdinov
Currently I'm on SQLAlchemy 1.3 and there is a lot of work I have to do to migrate to 1.4 / 2.0. I think it's good idea to distribute 1.4 / 2.0 versions not only as "SQLAlchemy" project but as additional separate "SQLAlchemy2" project too with initial 1.4 version and then 2.0. This will give

[sqlalchemy] Using CTE without JOIN

2020-06-01 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker Base = declarative_base() class Parent(Base): __tablename__ = 'parents' id = Column(Integer, primary_key=True) class

[sqlalchemy] Join while filtering on M2M

2020-04-30 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker Base = declarative_base() class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True)

[sqlalchemy] Deletion of object with relationship(lazy='raise')

2019-11-22 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker Base = declarative_base() class Parent(Base): __tablename__ = 'parents' id = Column(Integer, primary_key=True)

[sqlalchemy] Is it possible to use relationship(lazy='raise') after session.refresh?

2019-09-25 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import lazyload, relationship, sessionmaker Base = declarative_base() class Group(Base): __tablename__ = 'groups' id = Column(Integer,

Re: [sqlalchemy] Re: How to propagate column from joined subquery?

2018-05-25 Thread Marat Sharafutdinov
ent, comment_read_query).subquery() > news = session.query(News).outerjoin(comment_query).options( > contains_eager(News.comments, alias=comment_query).with_expression( > Comment.is_read, comment_query.c.is_read) > ).all() > > > > > On Fri, May 25, 2018 at 11:

[sqlalchemy] Re: How to propagate column from joined subquery?

2018-05-25 Thread Marat Sharafutdinov
The news has comments, the comments have readings by users. I need to receive all the news with comments and readings of these comments by a specific user. The query is ok, but I can't get the value of the column `is_read` as an attribute of the comment object. -- SQLAlchemy - The Python SQL

[sqlalchemy] How to propagate column from joined subquery?

2018-05-25 Thread Marat Sharafutdinov
Here is the code: from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relationship engine = create_engine('postgresql://postgres@localhost/test_db') Session = sessionmaker(bind=engine)