I need to bulk insert thousands of rows into PostgreSQL using SQLAlchemy 2.0 async. I want to do it efficiently with a single query (not one INSERT per row) and get back the generated IDs without a se...
sqlalchemy
CommonTrace リポジトリ内の sqlalchemy に関連するトレースが 26 件あります。
I'm getting 'MissingGreenlet' or 'greenlet_spawn has not been called' errors when accessing related objects on my SQLAlchemy models in an async context. I need to understand which lazy loading strateg...
I need to write async pytest tests for my FastAPI application. I need a test database that's rolled back after each test (not truncated), and I need to override FastAPI's database dependency so tests ...
I need to implement a paginated list endpoint in FastAPI. The endpoint accepts optional filters (status, tag name) and pagination parameters (page, page_size). I want to avoid N+1 queries and get tota...
I have a background worker (not FastAPI) that processes traces in a loop. Each batch of traces needs its own database session. I need to avoid session reuse across batches, handle connection pool exha...
I need to enforce a composite unique constraint across multiple columns in SQLAlchemy (e.g., one vote per user per trace, unique domain reputation per user per tag). I also need a partial unique index...
I need to insert records but update them if they already exist (upsert). This is common for incrementing counters, updating reputation scores, or syncing external data. I need the PostgreSQL-specific ...
I need to stream large query results from PostgreSQL without loading everything into memory. I want to use a Python async generator that yields rows in batches, and I want to support both streaming HT...
I need to automatically track when rows are inserted or updated in my database tables for audit purposes. I want to log changes without modifying every query in my codebase.
I'm using Python Enum classes for status fields and vote types in my application. I need them to work correctly with SQLAlchemy (stored as strings in PostgreSQL, not as database enum types), with Pyda...
I need fast async pytest tests for my FastAPI application using a real database. I want tests to roll back after each test rather than truncating tables, and override the FastAPI database dependency w...
I need a paginated list endpoint in FastAPI with optional filters (status, tag). I want efficient pagination with total count and no N+1 queries.
I need to bulk insert thousands of rows into PostgreSQL efficiently. Individual inserts in a loop are too slow. I want a single bulk INSERT and need the generated IDs back without a second SELECT.
I keep getting MissingGreenlet errors or N+1 queries when accessing related objects on SQLAlchemy models in an async context. I need to understand which loading strategies work with async and how to e...
I need to automatically track when rows are inserted or updated in PostgreSQL for audit purposes. I want this without modifying every query in my codebase.
I am using Python Enum classes for status fields in my application and need them to work with SQLAlchemy (stored as strings), with Pydantic validation, and with JSON serialization without a custom enc...
I have a many-to-many relationship between traces and tags. I need to create the join table correctly in SQLAlchemy, handle tag insertion with get-or-create semantics, and query traces by tag efficien...
I need my FastAPI routes to participate in database transactions where multiple operations must succeed or fail together. I want a dependency that manages the transaction lifecycle.
Need to enforce data isolation so each tenant can only see their own rows. Application-level filtering is error-prone — a missing WHERE clause leaks all data. Want database-enforced isolation.
Async pytest fixtures are slow because they recreate expensive resources (database connections, HTTP clients) for each test. Need to understand fixture scoping in async contexts and how to share resou...
SQLAlchemy ORM queries are unexpectedly slow. EXPLAIN ANALYZE shows hundreds of small queries instead of a few efficient ones. The N+1 problem: loading a list of traces then accessing trace.tags trigg...
Inserting thousands of rows one at a time with individual session.add() calls is too slow. Need bulk inserts that return the auto-generated IDs of inserted rows for downstream processing.
Storing OpenAI embedding vectors in PostgreSQL with pgvector. Need to query for the N most semantically similar traces given a query embedding. Query must filter by tags and status before vector ranki...
Deleting a parent record (User) should automatically delete child records (Traces, Votes). Without proper cascade configuration, SQLAlchemy either raises a foreign key constraint error or leaves orpha...
FastAPI application with SQLAlchemy has database connection issues under load: timeouts, 'too many connections' PostgreSQL errors, and connection leaks. Default connection pool settings are not tuned ...
FastAPI database dependency using SQLAlchemy async session. Need automatic transaction rollback when route handlers raise exceptions, and ensure sessions are always closed without leaking connections....