Re: [sqlalchemy] Why was the column information stripped away in SA 1.4.20 that existed in 1.3.20?

2021-08-31 Thread Gord Thompson
*With version 1.3:* Base = declarative_base() class User(Base): __tablename__ = "user" id = Column(Integer, primary_key=True) name = Column(String) Base.metadata.create_all(engine) print(pd.__version__) # 1.3.2 print(sa.__version__) # 1.3.24 session = Session(engine)

[sqlalchemy] ORM query returning separate columns instead of objects

2021-08-31 Thread Gord Thompson
My memory is failing me. I seem to recall that there was a succinct way to get a 1.4/2.0 ORM query to return individual columns instead of ORM objects. That is, to tell this print(session.execute(select(User)).fetchall()) # [(<__main__.User object at 0x0090175EC700>,)] to return the

Re: [sqlalchemy] Why was the column information stripped away in SA 1.4.20 that existed in 1.3.20?

2021-08-31 Thread Mike Bayer
On Tue, Aug 31, 2021, at 3:10 PM, Terrence-Monroe: Brannon wrote: > > Creating a pandas dataframe that contained descriptive column names formerly > was as easy as: > > result_set = session.query(cls.column_1) > df = pandas.Dataframe(result_set) > print df.column_1 > > but while this works

[sqlalchemy] Re: Why was the column information stripped away in SA 1.4.20 that existed in 1.3.20?

2021-08-31 Thread Gord Thompson
One option would be to replace result_set = session.query(cls.column_1) with result_set = session.execute(select(cls.column_1)).mappings().all() On Tuesday, August 31, 2021 at 1:10:17 PM UTC-6 thequie...@gmail.com wrote: > > Creating a pandas dataframe that contained descriptive column names

[sqlalchemy] Why was the column information stripped away in SA 1.4.20 that existed in 1.3.20?

2021-08-31 Thread Terrence-Monroe: Brannon
Creating a pandas dataframe that contained descriptive column names formerly was as easy as: result_set = session.query(cls.column_1) df = pandas.Dataframe(result_set) print df.column_1 but while this works in 1.3.20, in later versions of SA such as 1.4.19, there is not enough column info

Re: [sqlalchemy] Using SQLAlchemy to check if column is in numeric ranges

2021-08-31 Thread Simon King
You want a combination of the "between" function/method: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.between ...and the "or_" function: https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.or_ Something like this: ranges = [(18,

Re: [sqlalchemy] Selectinload and bindparam

2021-08-31 Thread Mike Bayer
this is true, the parameters can't be known to be passed along to a secondary query. the approach here would require that you make careful use of custom user options and events in order to make it work. the general event hook you would use is documented at

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Mike Bayer
issue https://github.com/sqlalchemy/sqlalchemy/issues/6963 is added to deal with possibly multiple failure modes in this case. On Tue, Aug 31, 2021, at 10:24 AM, Mike Bayer wrote: > Hi - > > Your test case is omitting a critical detail which we would assume is you are > using the

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Mike Bayer
Hi - Your test case is omitting a critical detail which we would assume is you are using the "implicit_returning=False" flag on your create_engine().dont use this flag as it serves no useful purpose and that will fix your issue here, we will be deprecating and removing this flag. will try

[sqlalchemy] Using SQLAlchemy to check if column is in numeric ranges

2021-08-31 Thread chat...@gmail.com
Hello All!! , I have a list of age ranges i.e 18-25, 40-55 and more how can I make make a query using *SQLAlchemy* that will check if a Column is in ranges [18,25] OR [40-55] OR [60-70] Regards,Christos -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

Re: [sqlalchemy] Selectinload and bindparam

2021-08-31 Thread Tomas Pavlovsky
Sorry, once again :) class X(Base): id: int = Column('x_id', Integer, primary_key=True, autoincrement=True) a_id: int = Column('a_id', Integer, ForeignKey('a.a_id')) a = relationship(A) s = select(A).where(A.id == 1) s = s.options(joinedload(A.b_filtered_rel)) or s =

Re: [sqlalchemy] Selectinload and bindparam

2021-08-31 Thread Tomas Pavlovsky
Hello Mike, Thank you very much for your response. I ended up with that, but i wanna ask you about this solution. class A(Base): id: int = Column('a_id', Integer, primary_key=True, autoincrement=True) #descr class B(Base): id: int = Column('b_id', Integer, primary_key=True,

[sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Francesca L
Hi group, I am tring to migrate from version *1.3.24* to *1.4.23* of SqlAlchemy, using *PostgreSQL 10*. I found that the following code example works with 1.3, but triggers a traceback with 1.4. import sqlalchemy session = ... metadata = sqlalchemy.MetaData() s_items =