[sqlalchemy] sqlalchemy 2.0 and ABCMeta

2023-11-09 Thread 'Iwan Vosloo' via sqlalchemy
Hi there, We are migrating our code from SqlAlchemy 1.4 to 2.0 (2.0.23 to be specific). We have had the following, which allowed some classes inheriting from our Base to use an ABCMeta metaclass: --- class DeclarativeABCMeta(DeclarativeMeta

Re: [sqlalchemy] Event listener for when query results get matched with pre-existing objects on the session

2023-10-22 Thread 'Tony Cosentini' via sqlalchemy
t 20, 2023, at 10:46 AM, 'Tony Cosentini' via sqlalchemy wrote: > > Oh I see, thanks for clarifying. > > I'm trying to detect cases where we depend on the autoflush behavior. For > example, in the sample above, when the query runs with no_autoflush, we > won'

Re: [sqlalchemy] Event listener for when query results get matched with pre-existing objects on the session

2023-10-20 Thread 'Tony Cosentini' via sqlalchemy
3, at 9:50 AM, 'Tony Cosentini' via sqlalchemy wrote: > > Weird, I did try that but I can't seem to trigger it. > > Here's a self-contained test: > https://gist.github.com/tonycosentini/4dee3478695d032ca67707b5e26739b6 > > > > the object was not affe

Re: [sqlalchemy] Event listener for when query results get matched with pre-existing objects on the session

2023-10-20 Thread 'Tony Cosentini' via sqlalchemy
ke_not_on_goo...@zzzcomputing.com> wrote: > > > On Fri, Oct 20, 2023, at 8:08 AM, 'Tony Cosentini' via sqlalchemy wrote: > > Hi, > > Is there any way to listen for an event for when a query result gets > merged into a pre-existing object in the session? > > > this

[sqlalchemy] Event listener for when query results get matched with pre-existing objects on the session

2023-10-20 Thread 'Tony Cosentini' via sqlalchemy
.all() query get merged back in with the existing objects in the session. Thanks, Tony -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverf

[sqlalchemy] Issue DELETE statement with LIMIT

2023-09-22 Thread 'Grennith' via sqlalchemy
n the claimed method is not callable like documented). This was the case in 1.4 (https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4/lib/sqlalchemy/sql/dml.py#L345) already and also in 2.0 (https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/sql/dml.py#L438). However, trying to c

[sqlalchemy] Temporarily disable/intercept ORM events on mutation

2023-09-15 Thread 'Luna Lucadou' via sqlalchemy
annot just leave it as-is). Unfortunately, this causes problems as SQLAlchemy attempts to handle the new value: Error Traceback (most recent call last): File "/Users/lucadou/IdeaProjects/person-api/api/unit_tests/test_person_service.py", line 601, in test_get_people_

Re: [sqlalchemy] sqlalchemy.orm.exc.FlushError on subclass

2023-09-14 Thread 'Luna Lucadou' via sqlalchemy
tails to the > concrete class you wish to persist and query, then you'd do the suggested > "enable_typechecks=False". There is no attribute in SQLAlchemy named > "meta" and no stack trace is given here so I dont know to what that refers. > > Overall

[sqlalchemy] sqlalchemy.orm.exc.FlushError on subclass

2023-09-06 Thread 'Luna Lucadou' via sqlalchemy
type polymorphically, or set enable_typechecks=False to allow any subtype to be accepted for flush. I did try setting enable_typechecks to False, but this results in a different error when attempting to use getattr on the subclass: AttributeError: 'Person' object has no attribute '

[sqlalchemy] Dogpile session caching

2023-08-02 Thread 'Joe Black' via sqlalchemy
query. This seems to break the example code for dogpile caching. I was hoping to get some advice on how to implement the caching using the new unified sa.select and Session.execute/Session.scalars interface, or even whether dogpile cache supports this interface yet? Thanks in advance, Joe

Re: [sqlalchemy] Should I use a surrogate primary key on an Association Object pattern?

2023-07-03 Thread 'Michael Mulqueen' via sqlalchemy
Hi Pierre, This isn't an official answer, I'm just a long time user of SQLAlchemy. Either way should work fine. The association object is driven by the columns on the association table being FKs, whether or not they're part of a PK isn't relevant. I've used both w

Re: [sqlalchemy] DRYing up model relationships with custom properties

2023-05-03 Thread 'Tony Cosentini' via sqlalchemy
pper so that you can apply > things after the fact, a good event for this would be "instrument_class": > https://docs.sqlalchemy.org/en/20/orm/events.html#sqlalchemy.orm.MapperEvents.instrument_class > > > On Wed, May 3, 2023, at 4:18 AM, 'Tony Cosentini' vi

[sqlalchemy] DRYing up model relationships with custom properties

2023-05-03 Thread 'Tony Cosentini' via sqlalchemy
he hood. Any ideas on if it's possible to combine this into some kind of reusable utility to DRY it up? I'm not sure how important it is, but I'm still on 1.4.x, haven't made the jump to 2.x yet. Thanks! Tony -- SQLAlchemy - The Python SQL Toolkit and Object Relationa

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
eliminate much of what the query is producing? From: 'Dan Stromberg [External]' via sqlalchemy Date: Tuesday, March 21, 2023 at 9:05 AM To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalEr

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
mberg [External]' via sqlalchemy Date: Tuesday, March 21, 2023 at 9:05 AM To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clau

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-21 Thread 'Dan Stromberg [External]' via sqlalchemy
ed to aggregate? Or perhaps change sql_mode? Thanks! From: sqlalchemy@googlegroups.com on behalf of Mike Bayer Date: Monday, March 20, 2023 at 5:33 PM To: noreply-spamdigest via sqlalchemy Subject: Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.Ope

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
Here’s the select, and most of the from clause: select nv.id, min(bs.build_id) as min_build_id from tb_v as v, tb_nv as nv, tb_bs as bs, tb_br as br, From: 'Dan Stromberg [External]' via sqlalchemy Date: Monday, March 20, 2023 at 2:16 PM To: sqlalchemy@googlegroups.com S

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
I’m getting some pushback internally, from my team lead – he and I both think it’s probably too much detail to share. It’s 43 lines of SQL with multiple subqueries. Would just the simplest parts of the from clause work? From: sqlalchemy@googlegroups.com on behalf of Mike Bayer Date

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-20 Thread 'Dan Stromberg [External]' via sqlalchemy
ch_id)) ) …which also gave: (1054, "Unknown column 'tb_br.id' in 'on clause'") I’m guessing I’m missing something simple, but I have no idea what. Any (further) suggestions? From: sqlalchemy@googlegroups.com on behalf of Mike Bayer Date: Saturday, Mar

Re: [sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-17 Thread 'Dan Stromberg [External]' via sqlalchemy
Sorry, I don’t know why Google Groups decided to aggregate a few lines into 2 large lines. Here’s that list of versions again. Hopefully GG will be appeased this time. I'm using: $ python3 -m pip list -v | grep -i sqlalchemy Flask-SQLAlchemy 2.5.1 /data/home/dstro

[sqlalchemy] Test query seems to spuriously give sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1054, "Unknown column 'tb_br.id' in 'on clause'")

2023-03-17 Thread 'Dan Stromberg' via sqlalchemy
r database host IDB Your initial database """ import os import pprint from sqlalchemy import create_engine, select from sqlalchemy.orm import aliased, sessionmaker, declarative_base from sqlalchemy.sql.expression import func from flask_sqlalchemy import SQLAlchemy db = SQLAlch

Re: [sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-05 Thread 'Tony Cosentini' via sqlalchemy
try adding > session.expunge_all() before the query and see if that makes things look > more expected. > > On Thu, Jan 5, 2023, at 1:27 AM, 'Tony Cosentini' via sqlalchemy wrote: > > Ok, I was able to at least create a script that easily reproduces what I'm >

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
b >>> property in the future, only specific columns are loaded in at first. >>> >>> I can do this if I just query for model_b via the foreign key instead of >>> using the relationship property, but I'd like to avoid that if possible. >>> >>>

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
at first. >> >> I can do this if I just query for model_b via the foreign key instead of >> using the relationship property, but I'd like to avoid that if possible. >> >> Sorry if this question is a bit weird/confusing, it's kind of a strange >> use c

[sqlalchemy] load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
use case. Thanks, Tony -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received thi

Re: [sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
uld be much appreciated! thanks >> >> https://www.sqlalchemy.org/blog/2022/11/12/sqlalchemy-1.4.44-released/ >> >> >> >> On Fri, Nov 11, 2022, at 11:42 AM, Mike Bayer wrote: >> >> We've identified a significant source of memory over-use in the 1.

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

2022-12-14 Thread 'dcs3spp' via sqlalchemy
ing an exception: *obj = MailingListView()obj.town = "town" # this raises an exception with unavailable property* How is it possible for a postgresql db (asyncpg) + async sqlalchemy to: Synchronise the columns of a declarative model with its underlying table after metadata reflection. Curr

Re: [sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2022-11-13 Thread 'Tony Cosentini' via sqlalchemy
ith your > application and let me know if you see improvements in memory use for your > memory-intensive case, that would be much appreciated! thanks > > https://www.sqlalchemy.org/blog/2022/11/12/sqlalchemy-1.4.44-released/ > > > > On Fri, Nov 11, 2022, at 11:42 AM, Mike Bay

[sqlalchemy] Breaking Integration with Locust Tests? Having a hard time debugging

2022-11-04 Thread 'Theo Chitayat' via sqlalchemy
stems from. Is there anything I can do to support this? Thanks in advance -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/

Re: [sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2022-11-03 Thread 'Tony Cosentini' via sqlalchemy
I'll report back if we see any changes. > > Thanks again for the fast reply (and for building such a useful + well > documented library), > Tony > On Friday, October 21, 2022 at 12:20:07 PM UTC+8 Mike Bayer wrote: > >> >> >> On Fri, Oct 21, 2022, at 12:

Re: [sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2022-10-21 Thread 'Tony Cosentini' via sqlalchemy
AM, 'Tony Cosentini' via sqlalchemy wrote: > > Hi, > > We recently upgraded our application (a Flask web app) from SQLAlchemy > 1.3.19 to 1.4.41. > > Overall things are stable, but we have noticed a very large increase in > memory use: > [image: Screen Shot 2022-10-

[sqlalchemy] Large increase in memory use when upgrading from 1.3 to 1.4

2022-10-20 Thread 'Tony Cosentini' via sqlalchemy
Hi, We recently upgraded our application (a Flask web app) from SQLAlchemy 1.3.19 to 1.4.41. Overall things are stable, but we have noticed a very large increase in memory use: [image: Screen Shot 2022-10-21 at 11.26.18 AM.png] Is this from the new query caching feature? I'm planni

[sqlalchemy] Re: Filling up a field in a database from a text file, flask

2022-08-22 Thread 'Jonathan Vanasco' via sqlalchemy
You should ask this in a Flask discussion group or stackoverflow. This is a sqlalchemy group and most users here have no experience with Flask. On Friday, August 19, 2022 at 4:13:50 PM UTC-4 nand...@gmail.com wrote: > I am trying to fill up a field in a table database with contents of a t

[sqlalchemy] Re: SQL Alchemy TypeDecorator

2022-08-09 Thread 'Jonathan Vanasco' via sqlalchemy
ithin the " > process_result_value" method of a TypeDecorator? > > For example, I want to decrypt the value but only if another value in the > same model row is true/false. > > Regards, > Justin > > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

[sqlalchemy] Re: SQLAlchemy exists() used with first() ?

2022-08-09 Thread 'Jonathan Vanasco' via sqlalchemy
I think you misunderstand `exists()` in SQLAlchemy and SQL. `exists()` is a convenience function to create a SQL `EXISTS` clause, which is an operator used for filtering subqueries. The 'from_exists' is just a subquery. It is supposed to be used within a query which would then

[sqlalchemy] Re: Shared ORM objects between threads

2022-07-05 Thread 'Ben Chopson' via sqlalchemy
27;t be passing ORM objects to threads, but rather >> just passing IDs and then querying the full object in the thread function. >> Does that hunch sound correct? >> > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post e

[sqlalchemy] Re: Shared ORM objects between threads

2022-07-05 Thread 'Jonathan Vanasco' via sqlalchemy
gt; I'm guessing we shouldn't be passing ORM objects to threads, but rather > just passing IDs and then querying the full object in the thread function. > Does that hunch sound correct? > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www

[sqlalchemy] Shared ORM objects between threads

2022-06-30 Thread 'Ben Chopson' via sqlalchemy
property. I'm guessing we shouldn't be passing ORM objects to threads, but rather just passing IDs and then querying the full object in the thread function. Does that hunch sound correct? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To

Re: [sqlalchemy] simple query takes to long

2022-06-08 Thread 'Jonathan Vanasco' via sqlalchemy
andas (and SQLAlchemy's ORM) is a lot of overhead - and that grows with the result size. You can use memory and code profiling tools to explore this and see where the issues are. The best approach is what Philip suggested above though, and not use pandas, so you can see how Python/SqlAlche

[sqlalchemy] Re: SQLALCHEMY conncection to Sybase Adaptive Server Anywhere Version 7 via TCI/IP

2022-04-14 Thread 'Jonathan Vanasco' via sqlalchemy
('IM002', '[IM002] >> [Microsoft][ODBC Driver Manager] Der Datenquellenname wurde nicht gefunden, >> und es wurde kein Standardtreiber angegeben (0) (SQLDriverConnect)') >> (Background on this error at: http://sqlalche.me/e/14/rvf5) >> >> i have i

[sqlalchemy] Re: SQLALCHEMY conncection to Sybase Adaptive Server Anywhere Version 7 via TCI/IP

2022-04-13 Thread 'Jonathan Vanasco' via sqlalchemy
The Sybase dialect was deprecated from first-party support by SQLAlchemy and is currently unsupported. Gord Thompson, who is a frequent contributor to the core SQLAlchemy project, and has generously taken over responsibility for the original dialect as a third-party dialect:: https

[sqlalchemy] Re: create database name lowcase ?

2022-03-31 Thread 'Jonathan Vanasco' via sqlalchemy
ABc"; CREATE DATABASE "ABC"; .. etc.. On Thursday, March 31, 2022 at 2:39:32 PM UTC-4 ois...@gmail.com wrote: > Hi everyone, I have a question > > I use Postgresql > Before creating a database, the name is uppercase and lowercase, and there > is no problem. >

Re: [sqlalchemy] Re: many-to-many orm warnings

2022-03-15 Thread 'Jonathan Vanasco' via sqlalchemy
I'm sorry you're getting bit by this messaging - but also glad that I'm not the only one. This got me a while ago too. SqlAlchemy just uses a bare field name when emitting the warning and accepting the `overlaps` arguments. In more complex models with 3+ tables that h

[sqlalchemy] Setting up indexes in __table_args__ that depend on columns created in __declare_first__

2021-12-14 Thread 'Randy Syring' via sqlalchemy
ationship(cls.__flaw_parent__, lazy='raise_on_sql')) I realize I have an event ordering issue with the way this is setup. Just not sure what the correct way is to solve it. Thanks in advance for any help you can provide. -- SQLAlchemy - The Python SQL Toolkit and Object Relational

Re: [sqlalchemy] How to SELECT computed data using SQLAlchemy?

2021-12-14 Thread 'Daniel Grindrod' via sqlalchemy
That worked brilliantly, thanks so much for your help! Very much appreciated :) On Tuesday, 14 December 2021 at 18:16:02 UTC Mike Bayer wrote: > > > On Tue, Dec 14, 2021, at 12:26 PM, 'Daniel Grindrod' via sqlalchemy wrote: > > Hi Michael, > > Thanks for such a q

Re: [sqlalchemy] How to SELECT computed data using SQLAlchemy?

2021-12-14 Thread 'Daniel Grindrod' via sqlalchemy
ete code I sent across). Could you please advise on how to correctly structure this query? Thanks again, Dan On Tuesday, 14 December 2021 at 13:31:12 UTC Mike Bayer wrote: > > > On Tue, Dec 14, 2021, at 5:40 AM, 'Daniel Grindrod' via sqlalchemy wrote: > > Hi all, > &

[sqlalchemy] How to SELECT computed data using SQLAlchemy?

2021-12-14 Thread 'Daniel Grindrod' via sqlalchemy
Hi all, I'm working on a REST API which is built using Flask-SQLAlchemy and Connexion. I'm fairly new to SQLAlchemy, but it's been brilliant so far :) This API uses SQLAlchemy 1.3.16, and connects to an Oracle Database (12c 12.1.0.1.0 64bit). <https://stackoverflow.com/posts

[sqlalchemy] Re: Calculate rank of single row using subquery

2021-09-14 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
g table data - the structure, size, etc. Adding indexes on columns can often improve performance a lot. If you're really concerned on optimizing this, the typical approach is to focus on generating the target SQL query that works within the performance constraints you want, and then porting it t

[sqlalchemy] Re: AsyncEngine always returns UTC time for datetime column

2021-09-14 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
any help is appreciated? > > I am working with sqlalchemy core and async engine. Column definition: > *Column('test', DateTime(timezone=True), nullable=False)* > > Also tried with this, but no luck: > > *_connect_args = {'server_settings': {'

Re: [sqlalchemy] Change in before_flush (maybe from 1.3 to 1.4?)

2021-09-09 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
certain attributes null) and never commit them to the > database (in before_flush). > > I realise this is a somewhat confusing question, sorry, and I can probably > fix my code anyway. I am just looking for some peace of mind in > understanding how on earth it ever worked. > > Than

[sqlalchemy] Re: sqlite setting foreign_keys=off temporarily

2021-08-10 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
The first two things I would look into: 1. Check the sqlite install/version that SqlAlchemy uses. It is often NOT the same as the basic operating system install invoked in your terminal. Sometimes that version does not have the functionality you need. 2. Check the transactional isolation

Re: [sqlalchemy] Join multiple tables with association tables

2021-08-10 Thread 'timbecks&#x27; via sqlalchemy
Info meant to be many-to-many? And likewise > the relationship between Text and Info? > > Forgetting SQLAlchemy for a moment, what is the SQL that you want to > produce? > > > Does the script below do what you want? > > > import sqlalchemy as sa > import sqlalche

[sqlalchemy] Join multiple tables with association tables

2021-08-09 Thread 'timbecks&#x27; via sqlalchemy
I am trying to figure out the correct join query setup within SQLAlchemy, but I can't seem to get my head around it. I have the following table setup (simplified, I left out the non-essential fields): [image: Unbenannt.png] [image: Unbenannt2.png] The facts are associated to info, in

[sqlalchemy] Join multiple tables with association tables

2021-08-09 Thread 'timbecks&#x27; via sqlalchemy
I am trying to figure out the correct join query setup within SQLAlchemy, but I can't seem to get my head around it. I have the following table setup (simplified, I left out the non-essential fields): ```pyhton "facts_info", Base.metadata, sqlColumn("fact_id", Int

[sqlalchemy] Join multiple tables with association tables

2021-08-09 Thread 'timbecks&#x27; via sqlalchemy
I am trying to figure out the correct join query setup within SQLAlchemy, but I can't seem to get my head around it. I have the following table setup (simplified, I left out the non-essential fields): ```pyhton "facts_info", Base.metadata, sqlColumn("fact_id", Int

[sqlalchemy] Re: Oracle connection problem

2021-08-06 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
; I am using sqlalchemy 1.4.22 and cx oracle 8.2.1 to connect to production > and development environments that each host a similar copy of the same > schema. > > The connection string that I use is the same for each excluding the > password: > > oracle+cx_oracle://user:

[sqlalchemy] Re: Testing and deprecation of nested transactions

2021-07-30 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
:19:35 AM UTC-4 dcab...@gmail.com wrote: > Hello everyone, > > I am working on a new project using SqlAlchemy Core 1.4 with Postgresql > and wanted to implement the following pattern for my tests: > > - Before each test I would start a transaction (in a > @pytest.fixture(autoru

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
> > Hope that helps, > > Simon > > On Fri, Jul 30, 2021 at 5:10 PM 'Jonathan Vanasco' via sqlalchemy > wrote: > > > > Mike, thanks for replying but go back to vacation. > > > > Anyone else: I am thinking more about an event that can be used to

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
//docs.sqlalchemy.org/en/14/core/custom_types.html#coercing-encoded-strings-to-unicode > > > > On Thu, Jul 29, 2021, at 5:17 PM, 'Jonathan Vanasco' via sqlalchemy wrote: > > I am finally at the tail end of migrating my largest (and hopefully last) > Python2 applicatio

[sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-29 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
I am finally at the tail end of migrating my largest (and hopefully last) Python2 application to Python3. An issue that has popped up a lot during this transition, is when a py3 bytestring gets submitted into SqlAlchemy. When that happens, it looks like SqlAlchemy just passes the value into

[sqlalchemy] Re: sqlacodegen bug ?

2021-07-17 Thread 'Sebastian Cheung&#x27; via sqlalchemy
e problem today, found your post by searching for "sqlacodegen table > class." > > Something in this semi-unrelated post > <https://groups.google.com/d/msg/sqlalchemy/uQ7MijlHW1Y/3xaA7vJ6BwAJ> by > Mike Bayer prompted me to check to see what was different about the

[sqlalchemy] Re: checking in

2021-06-21 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
> If not I wonder why messages aren't arriving in my INBOX. Check your settings for this group. If you do not see the option on the menu, try visiting https://groups.google.com/g/sqlalchemy/membership Google sometimes has a product change de-selects the email delivery option. Sometim

Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-10 Thread 'Matt Zagrabelny&#x27; via sqlalchemy
BUG:sqlalchemy.engine.base.Engine:Col ('id',) DEBUG:sqlalchemy.engine.base.Engine:Row (19,) INFO:sqlalchemy.engine.base.Engine:COMMIT Should I be seeing something in the logs about an invalidated connection? Or am I not forcing an invalid connection correctly? Thanks for the feedback! -m

Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-08 Thread 'Matt Zagrabelny&#x27; via sqlalchemy
parameters are of my particular failure. Pre ping doesn't seem like it allows for any sort of length of time before failing. I don't know if this offers any more clarity to what I'm experiencing and what I'm trying to code around. Thanks again for the help and dialogue! -m

Re: [sqlalchemy] Session and optimistic disconnect handling

2021-06-08 Thread 'Matt Zagrabelny&#x27; via sqlalchemy
ns mid transaction) and because I felt I could control the number of retries and put in an exponential backoff. Do you suggest I use the custom pessimistic ping code: https://docs.sqlalchemy.org/en/14/core/pooling.html#custom-legacy-pessimistic-ping to add in exponential backoff or add addit

[sqlalchemy] Session and optimistic disconnect handling

2021-06-07 Thread 'Matt Zagrabelny&#x27; 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&#x27; 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: > >

[sqlalchemy] correct usage of next_value for a sequence

2021-04-20 Thread 'Matt Zagrabelny&#x27; 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

Re[4]: [sqlalchemy] Invertinace mapped type_id to fix value for each child class

2021-04-12 Thread 'Sören Textor&#x27; via sqlalchemy
t;: ChildClass.TypID(), } And as I said: Thanks a lot! SirAnn -- Originalnachricht -- Von: "Simon King" An: sqlalchemy@googlegroups.com Gesendet: 12.04.2021 20:26:48 Betreff: Re: Re[2]: [sqlalchemy] Invertinace mapped type_id to fix value for each child class Here&

Re[2]: [sqlalchemy] Invertinace mapped type_id to fix value for each child class

2021-04-12 Thread 'Sören Textor&#x27; via sqlalchemy
_mapper_args__ = { 'polymorphic_identity': 7, } leads to: venv\lib\site-packages\sqlalchemy\orm\mapper.py", line 1542, in _configure_polymorphic_setter self.polymorphic_on = self._props[self.polymorphic_on] KeyError: 'typ_id' raise exception sqlalchem

[sqlalchemy] Inheritnace mapped type_id to fix value for each child class

2021-04-12 Thread 'Sören Textor&#x27; via sqlalchemy
fact that type_id ha a foreign key ... right know I get an error: c = ChildClass() db.session.add(c) db.session.commit() c.typ -> UnmappedColumnError('No column objekt.typ_id is configured on mapper mapped class ChildClass1->child_class1...') SirAnn -- SQLAlchemy - The Python SQL To

[sqlalchemy] Invertinace mapped type_id to fix value for each child class

2021-04-12 Thread 'Sören Textor&#x27; via sqlalchemy
ekt.id'), primary_key=True) text = db.Column(db.String(255 ), default='') __mapper_args__ = { 'polymorphic_identity':'child_class1', } any ideas where to look? I though on polymorphic_on, but I think that does not work because of the fact th

[sqlalchemy] Re: (cx_Oracle.DatabaseError) ORA-00972

2021-03-22 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
#sqlalchemy.create_engine.params.label_length I don't have Oracle, so I am not sure if this fixes your exact problem or just related ones. `label_length` will limit the length of aliases that sqlalchemy generates. so you would see something like this: - SELECT very_long_table_name_i_mean_it_is_long.

Re: [sqlalchemy] Injecting User info into _history table to track who performed the change

2021-03-15 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
Going beyond what Simon did.. I typically make make a table like `user_transaction`, which has all of the relevant information for the transaction: * User ID * Timestamp * Remote IP Using the sqlalchemy hooks, I'll then do something like: * update the object table with the user_transacti

Re: [sqlalchemy] Supporting Function Indexes on a Minimum Sqlite Version

2021-03-09 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
27;Jonathan Vanasco' via sqlalchemy wrote: > > I have a project that, in a few rare situations, may run on a version of > sqlite that does not support function indexes, and "need" to run a unique > index on `lower(name)`. For simplicity, I'll just use a normal i

[sqlalchemy] Supporting Function Indexes on a Minimum Sqlite Version

2021-03-08 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
ay to implement this. 1. in terms of sqlite3, what is the best way to access the version Sqlalchemy is using? the import is in a classmethod, and could either be pysqlite2 or sqlite3? i seriously doubt anyone would deploy with pysqlite2, but I feel like I should do things the right way. 2. Wha

Re: [sqlalchemy] relationship query_class in SQLAlchemy 1.4.0b3

2021-03-01 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
version, and there are critical features/bugfixes in the newer branch. You're likely to get a good chunk of time out of 1.4, but I would not target 1.3 at this point. On Monday, March 1, 2021 at 9:45:55 AM UTC-5 aa@gmail.com wrote: > yes so, SQLAlchemy 2.0's approach is frankly

Re: [sqlalchemy] Batching INSERT statements

2021-02-12 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
ery row. On Friday, February 12, 2021 at 2:06:55 PM UTC-5 christia...@gmail.com wrote: > Hi Vineet, Mike, > > @Vineet, thank you for the interesting blog post on bulk insert with > SQLAlchemy ORM: > https://benchling.engineering/sqlalchemy-batch-inserts-a-module-for-when-y

[sqlalchemy] Re: Relationship with 2 intermediary tables

2021-02-12 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
This is, IMHO, one of the most complex parts of SQLAlchemy. In this public project, i have a handful of secondary/secondaryjoin examples that may help you https://github.com/aptise/peter_sslers/blob/main/peter_sslers/model/objects.py#L3778-L4714 There is a section in the docs that should help

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
he "twophase" flag which I > think we needed for some of our more elaborate tests. At the moment, > create_xid() emits a deprecation warning. I've been in contact with Oracle > devs and it looks like we should be supporting 2pc as I can get help from > them now

Re: [sqlalchemy] FAQ or Feature Ideas for ORM Object and Session

2021-01-27 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
Ok. I'll generate a docs PR for sqlalchemy and pyramid. this comes up so much. On Wednesday, January 27, 2021 at 2:25:29 PM UTC-5 Mike Bayer wrote: > > > On Wed, Jan 27, 2021, at 1:12 PM, 'Jonathan Vanasco' via sqlalchemy wrote: > > I've been working with

[sqlalchemy] FAQ or Feature Ideas for ORM Object and Session

2021-01-27 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
I've been working with a handful of SQLAlchemy and Pyramid based projects recently, and two situations have repeatedly come up: 1. Given a SQLAlchemy Object, access the SQLAlchemy Session 2. Given a SQLAlchemy Object or Session, access the Pyramid Request object The general solutions I&#x

[sqlalchemy] Re: SQLAlchemy transaction ID

2021-01-27 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
2021 at 8:32:34 AM UTC-5 tfl...@gmail.com wrote: > Hi, > I'm actually using SQLAlchemy with Pyramid and zope.sqlalchemy packages. > My main database connection is a ZODB connection and, when required, I > create an SQLAlchemy session which is joined to main transaction using this

Re: [sqlalchemy] Implementing Role-Based Access Control (RBAC) in SQLAlchemy with oso

2021-01-07 Thread 'Michael Mulqueen&#x27; via sqlalchemy
Glaser, wrote: > Hi all, we've been working towards building Role-Based Access Control > (RBAC) features into our libraries at oso. We had released a preview of > those features in our sqlalchemy-oso package, and since then have polished > those features up, written some

Re: [sqlalchemy] One to One relation problem [re-open?]

2020-12-18 Thread 'Sören Textor&#x27; via sqlalchemy
Ah. I see. Thus this was a newbie question. Thanks again! Mike Bayer schrieb am Fr. 18. Dez. 2020 um 19:44: > hey there - > > you can assign the "id" but that doesn't give SQLAlchemy any clue that you > are working with the "daughter" relationship so it does

Re: [sqlalchemy] One to One relation problem [re-open?]

2020-12-18 Thread 'Sören Textor&#x27; via sqlalchemy
This example fails. Instead of assigning an objekt, I assign just the daughters id ... But I think that's "correct"? from sqlalchemy import Column from sqlalchemy import create_engine from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy.ext.dec

[sqlalchemy] Re: One to One relation problem [solved]

2020-12-18 Thread 'Sören Textor&#x27; via sqlalchemy
Hi Mike Thanks for looking at my code. Next time I'll post an testcase like you. Sorry for that one. And I cannot believe it. But it works now. I also updated SQLAlchemy, flast-RESTful, flask-migrate and so on, to their newest version. And now it seems to work. And problem befor

[sqlalchemy] One to One relation problem

2020-12-17 Thread 'Sören Textor&#x27; via sqlalchemy
.session.commit() m1.daughter = d2 db.session.commit() everything is correct EXCEPT: *m2.daughter! *it still points on d2 instead of None. And the table contains still the daughter_id of d2. Thus, what foreign key did I miss? All the best and stay healthy! SirAnn -- SQLAl

Re: [sqlalchemy] Differences between TableClause insert and Model.__table__ inserts?

2020-11-25 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
This was not clear enough in Mike's post: `Foo.__table__` is the same type of object as `_foo = table(...)`. SQLAlchemy ORM is built on top of SQLAlchemy's Core, so the ORM's `.__table__` attribute is the Core's `table()` object. Since they're the same, the two will

[sqlalchemy] Re: Dis/Reassociate objects with a db session.

2020-11-25 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
-associate objects that belonged to the first session > with a newly opened one? What’s the recommended approach here, does SQLA > have any magic in store to help me with very long-lived ORM objects across > db sessions? Or should I manage that data independently of their respective >

[sqlalchemy] Re: Zope.sqalchemy: AttributeError: '_thread._local' object has no attribute 'value'

2020-10-25 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
Your new code is exactly what I have been running on several production systems, so it looks good to me! Long story short, `zope.sqlalchemy` had been using the `sqlalchemy` "extensions", which were deprecated in 2012 and are set to be removed (if they haven't been alread

[sqlalchemy] Recreating Access in LibreOffice Base

2020-10-22 Thread 'Tom Potts&#x27; via sqlalchemy
I used to find MS Access to be a very useful tool in the right hands. I've been doing some python script coding in LibreOffice Base and started looking at sqlalchemy it looks as if it wouldnt be too much of a job to add the components necessary to turn LO Base front end into something no

[sqlalchemy] Re: Update multiple rows in SQLite Databse

2020-08-28 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
the Unit of Work, as mike said, you need to delete and add (and also update it would seem). -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://s

Re: [sqlalchemy] How to disable the integer col + pk = serial behaviour?

2020-08-05 Thread 'Michael Mulqueen&#x27; via sqlalchemy
g using > executemany_mode='values'. > > My idea is to call nextval() on the sequence before insert and fill in the > values client side, before inserting. > > select nextval('mysql') FROM generate_series(1,...) > > Everything looks good, except for the

Re: [sqlalchemy] How can I query two fields in my database to confirm it exists and then delete

2020-08-04 Thread 'Michael Mulqueen&#x27; via sqlalchemy
ype and then remove.. > > so for example. if lesson_id matches 107 and the same entry includes > device_type_id = 7 i want to remove this whole entry > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To

[sqlalchemy] Re: sqlalchemy messes up names with "_1" suffix

2020-07-10 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
> i have this litte flask-admin game running, now out of nowwhere sqlalchemy has begun to add strange "_1" suffixes to the column names. i know sqlalchemy does this to keep names unique, but in my case the queries are failing SQLAlchemy does do this, for those reasons, and t

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
generates a > different string each encryption for the same string. > What are you using for your encryption key? The key should be persistent, and should always generate the same output for a given input. In the example from Michael Bayer, a random uuid is used as a placeholder. -- SQLA

Re: [sqlalchemy] convert subset to dictionary

2020-07-07 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
ly take a few ms to get all that into a python datastructure that is used to generate your csv -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http:

[sqlalchemy] Re: SQLAlchemy taking too much time to process the result

2020-07-06 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
On Monday, July 6, 2020 at 2:14:33 PM UTC-4, Saylee M. wrote: > So, when I passed the query to MySQL directly, it took very less time > (around 0.016 seconds) but when I passed the same > query through SQLAlchemy connector, it took around 600 seconds > "query ... MySQL

[sqlalchemy] Re: Locking method used in SQLAlchemy (postgres)

2020-06-30 Thread 'Jonathan Vanasco&#x27; via sqlalchemy
On Monday, June 29, 2020 at 8:00:40 PM UTC-4, gbr wrote: > > > I'm using SQLAlchemy's Core to interface a postgres database (via > psycopg2) component alongside Flask-SQLAlchemy in a Flask app. Everything > was working fine until I recently discovered what seems to be

  1   2   3   >