Re: [sqlalchemy] Composite columns and None

2024-02-15 Thread jens.t...@gmail.com
I wanted to follow up on this thread. Mike’s suggestion above worked, and considering the related discussion Dataclasses and Composites with init-only variables I

Re: [sqlalchemy] Composite columns and None

2023-11-26 Thread jens.t...@gmail.com
Thank you, Mike, for the suggestion! Another thought I mulled over was to create a new *point* table and then use a nullable FK from the *vertex* table. That way, the *Point* class can map to its own dedicated table, and a *Vertex* class would then use a relationship that’s able to map

[sqlalchemy] Re: Composite columns and None

2023-11-14 Thread jens.t...@gmail.com
, although if any one mapped properties is NULL then by definition to Point would be invalid. Hmm 樂 On Wednesday, November 15, 2023 at 9:02:16 AM UTC+10 jens.t...@gmail.com wrote: > Hello everyone, > > I wanted to follow up on the examples on Composite Column Types > <https://docs.sq

[sqlalchemy] Composite columns and None

2023-11-14 Thread jens.t...@gmail.com
Hello everyone, I wanted to follow up on the examples on Composite Column Types and in particular setting the mapped composite value in Python-land to *None*. For instance, this class @dataclasses.dataclass class Point: x: int y:

Re: Migrate alembic_version table from Public to tenant schema

2023-08-20 Thread jens.t...@gmail.com
Thank you Brian and Mike, just the conversation I was looking for. One follow-up question — is this a one-time step, and can I point all subsequently generated/applied migrations to the new schema and version_table? I think, Brian, your question regards a permanent migration of the table

[sqlalchemy] Seeking experience/suggestions regarding connection pools

2023-07-13 Thread jens.t...@gmail.com
Hello, The SQLA Pooling section says that the default connection pool (QueuePool is the default pool, isn’t it?) has 5 connections with an overflow of 10 (docs

[sqlalchemy] How to LOCK TABLE for PostgreSQL

2023-02-23 Thread jens.t...@gmail.com
Hello, In order to use the PostgreSQL LOCK with SQLAlchemy, is there a better way than *session.execute(sa.text(f"LOCK TABLE {Foo.__tablename__} IN SHARE MODE"))* Poking through the dialect

Re: [sqlalchemy] Can’t make the Composite Comparator work…

2022-09-16 Thread jens.t...@gmail.com
Thank you Simon! That worked indeed and makes a lot of sense. I think I misinterpreted the documentation a bit in that sense; it did puzzle that SQLA would patch all these mapped objects… Based on your example: *>>> dbsession.query(Vertex).filter(Vertex.start > Point(2, 2)).all()*

[sqlalchemy] Can’t make the Composite Comparator work…

2022-09-16 Thread jens.t...@gmail.com
Hello, I’m noodling through the Composite Column Types examples, and can’t make it work. Based on the code on that page I put together a minimal, reproducible example

[sqlalchemy] SQLAlchemy 2 and Dialect’s has_schema()

2022-07-31 Thread jens.t...@gmail.com
Hello, I’m curious to get recommendations about the following use-case (based on this SO Answer ): *>>> import sqlalchemy* *>>> configuration = {'sqlalchemy.url':

Re: [sqlalchemy] Re: With declarative_base() can I assign different mappings to different engines?

2022-07-29 Thread jens.t...@gmail.com
Thank you, Mike! I’m still a little unclear: how would I use different *MetaData* for different sets of tables? For example, currently I use this function: *def create_base(schema: typing.Optional[str] = None) -> typing.Any: return declarative_base(cls=_Base,* *

[sqlalchemy] Re: With declarative_base() can I assign different mappings to different engines?

2022-07-28 Thread jens.t...@gmail.com
CustomBase: typing.Any = create_base(schema="foo")* Is there a better way to type-hint *CustomBase* here? On Thursday, July 28, 2022 at 10:09:26 PM UTC+10 jens.t...@gmail.com wrote: > Hello, > > I’m using a *Base = declarative_base() > <https://docs.sqlalchemy.o

[sqlalchemy] With declarative_base() can I assign different mappings to different engines?

2022-07-28 Thread jens.t...@gmail.com
Hello, I’m using a *Base = declarative_base() * in a single, shared package that other packages can import and use. Now suppose I have two more packages, each of which declares a bunch of mappings using

[sqlalchemy] Where could I post db job openings?

2022-06-05 Thread jens.t...@gmail.com
Hello all, I’m trying to find a good place to post a job opening for a solid SQLA/PostgreSQL/Python db developer (contract or permanent). Not sure this group is suited for this, but I hope somebody may be able to point me at well-frequented job board? Much thanks! Jens -- SQLAlchemy - The

Re: [sqlalchemy] Looking for help with interpreting an error/debugging

2022-05-09 Thread jens.t...@gmail.com
FWIW, after switching drivers I haven’t seen this issue again… (Please let’s not jinx it!) Jens On Monday, March 28, 2022 at 11:10:26 PM UTC+10 Mike Bayer wrote: > there's probably something up with that server so you will still get > errors, but at least they will be familiar looking > --

Re: [sqlalchemy] Looking for help with interpreting an error/debugging

2022-03-28 Thread jens.t...@gmail.com
Thank you Mike for your prompt response! I opened an issue CONPY-197 , let’s see what comes of that. I’ve used mysql+pymysql:// quite happily in the past with a MySQL db, and when we switched to MariaDB I switched the drivers. It didn’t occur to me

[sqlalchemy] Looking for help with interpreting an error/debugging

2022-03-28 Thread jens.t...@gmail.com
Hello, I’m utterly stomped by this problem and I hope that the wisdom of the crowd (and the much more experienced users here) can point me into the right direction. I’ve got a single MariaDB (Ver 15.1 Distrib 10.6.5-MariaDB, for Linux (x86_64)) running natively on a

Re: [sqlalchemy] PostgreSQL UUID type, Python’s UUID — and type hints

2022-01-25 Thread jens.t...@gmail.com
Mike, I really appreciate your responses, thank you! All makes sense 邏 Jens On Tuesday, January 25, 2022 at 4:06:03 PM UTC+10 Mike Bayer wrote: > > > On Mon, Jan 24, 2022, at 11:32 PM, jens.t...@gmail.com wrote: > > Mike, thank you for elaborating, that helps a lot! Yes, I me

Re: [sqlalchemy] PostgreSQL UUID type, Python’s UUID — and type hints

2022-01-24 Thread jens.t...@gmail.com
, 2022 at 1:04:46 AM UTC+10 Mike Bayer wrote: > > > On Sat, Jan 15, 2022, at 3:34 PM, jens.t...@gmail.com wrote: > > Hello Mike, > > Yes that’s using the plugin: > sqlalchemy[mypy,postgresql_psycopg2binary]==1.4.29 I changed the function > declaration to this: >

Re: [sqlalchemy] PostgreSQL UUID type, Python’s UUID — and type hints

2022-01-15 Thread jens.t...@gmail.com
Hello Mike, Yes that’s using the plugin: sqlalchemy[mypy,postgresql_psycopg2binary]==1.4.29 I changed the function declaration to this: @staticmethod def create(dbsession: Session, name: str, id_: typing.Union[uuid.UUID, sqlalchemy.dialects.postgresql.base.UUID] = None): and it seems

[sqlalchemy] PostgreSQL UUID type, Python’s UUID — and type hints

2022-01-12 Thread jens.t...@gmail.com
Hello, For a PostgreSQL 14 db, I defined a User mapping and helper function like so: from sqlalchemy.dialects.postgresql import UUID class User(Base): id = Column(UUID(as_uuid=True), primary_key=True, server_default=func.gen_random_uuid()) name = Column(Unicode(128))

[sqlalchemy] Current experiences with async Python and dbs?

2021-12-19 Thread jens.t...@gmail.com
Hello, We’ve been debating the performance of “standard” Python vs. async Python lately, in the context of db-backed web services. For web services, the blog Async Python is not faster

Re: [sqlalchemy] raise error on insert/update PK?

2021-11-18 Thread jens.t...@gmail.com
Tim, I wanted to offload the UUID generation for the PK to the server ( server_default instead of just default argument). But I wasn’t able to find gen_random_uuid() documented in the PostgreSQL dialect

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

2020-11-25 Thread jens.t...@gmail.com
Hello, My question is regarding long-running tasks and db sessions. Currently I have the very rare situation where a task takes longer than a db session is valid and thus fails when it wants to write back results. Extending the TTL of a db session is probably not a good idea. I think the