Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-10 Thread 'Matt Zagrabelny' via sqlalchemy
On Tue, Jun 8, 2021 at 11:58 AM Mike Bayer wrote: > > Unknown network failures, I suppose. I have an application that is > throwing an exception right now due to: > > psycopg2.OperationalError: terminating connection due to administrator > command > SSL connection has been closed unexpectedly >

Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-08 Thread 'Matt Zagrabelny' via sqlalchemy
On Tue, Jun 8, 2021 at 10:28 AM Mike Bayer wrote: > > > > however, I would advise using pool_pre_ping instead which is much easier > to use and has basically no downsides.this feature didn't exist when > the docs for "optimistic disconnect" were written. > > > Sure. I was only looking at

Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-08 Thread 'Matt Zagrabelny' via sqlalchemy
Hi Mike, Thanks for the reply! On Mon, Jun 7, 2021 at 6:08 PM Mike Bayer wrote: > ORM Sessions ride on top of connections, but since the Session under it's > default pattern of being bound to an Engine does the "connect" internally, > it's probably inconvenient to adapt the optimistic

[sqlalchemy] Session and optimistic disconnect handling

2021-06-07 Thread 'Matt Zagrabelny' via sqlalchemy
Greetings SQLAlchemy folks, I am following the guide at [0] for recovering from a database error in my SQLAlchemy code. I normally use sessions for my SA work and am wondering if sessions will work with the aforementioned SA example. My initial attempt to combine the example at [0] with sessions

Re: [sqlalchemy] correct usage of next_value for a sequence

2021-04-20 Thread 'Matt Zagrabelny' via sqlalchemy
On Tue, Apr 20, 2021 at 1:14 PM Mike Bayer wrote: > > > On Tue, Apr 20, 2021, at 1:52 PM, 'Matt Zagrabelny' via sqlalchemy wrote: > > Greetings SQLAlchemy, > > I'm attempting to use the next_value function to get the (next) value from > a sequence: > > cycle

[sqlalchemy] correct usage of next_value for a sequence

2021-04-20 Thread 'Matt Zagrabelny' via sqlalchemy
Greetings SQLAlchemy, I'm attempting to use the next_value function to get the (next) value from a sequence: cycle_counter = next_value(Sequence('cycle_seq')) print(cycle_counter) However, the print statement yields: Does anyone know the correct way to get the value of a

Re: [sqlalchemy] Re: converting row object to dict

2018-08-25 Thread Matt Zagrabelny
Thanks for the help Jonathan and Mike. -m On Sat, Aug 25, 2018 at 8:16 AM, Mike Bayer wrote: > just as a note, that's also not a "row" object you are getting back, you > are getting ORM mapped instances. if you want rows which you can call > dict() directly on them, use a Core expression,

[sqlalchemy] converting row object to dict

2018-08-24 Thread Matt Zagrabelny
Greetings, I've searched the group archives and looked at StackOverflow (sorry!) and couldn't come up with the canonical way to convert a row object to a dict. Here are some code snippets: Base = declarative_base() class Station( Base, ): __tablename__ = 'stations' id=

[sqlalchemy] standalone asc/desc function vs ColumnElement asc/desc function

2018-02-28 Thread Matt Zagrabelny
Greetings, Are there any reasons (canonical, stylistic, etc.) that one would use order_by(desc(Class.column)) vs order_by(Class.column.desc()) ? Thanks! -m -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please

Re: [sqlalchemy] Performance of ORDER BY vs. list.sort() vs. sorted()

2018-02-28 Thread Matt Zagrabelny
On Wed, Feb 28, 2018 at 3:02 PM, wrote: > Hello, > > I’m curious about your experience with sorting the results of all() > > queries which return a list. It seems to me that there are

Re: [sqlalchemy] Composite primary key with nullable columns

2016-01-05 Thread Matt Zagrabelny
On Tue, Jan 5, 2016 at 11:11 AM, Paul Johnston wrote: > Hi, > > I have a situation where I'm trying to us a composite primary key, where one > of the columns can be null. > > However, when I try to update an object I get the following error: > sqlalchemy.orm.exc.FlushError:

[sqlalchemy] passing a dictionary to a Base derived constructor?

2015-11-30 Thread Matt Zagrabelny
Greetings, I've googled a bit, checked the sqlalchemy group archives, and looked at the API for resolution to the following question, but came up short on a definitive answer. I've got a table with a number of fields. It is defined as such: from sqlalchemy.ext.declarative import