# sqlalchemy.exc.InvalidRequestError: Could not assemble any primary key columns for mapped table 'orders'

- **ID:** `python/sqlalchemy-could-not-assemble-mapper`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The mapped table lacks a primary key definition, either because no column is marked as primary_key or because the table inherits from a select that doesn't have one.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (100% success)
   ```
   class Order(Base):
    __tablename__ = 'orders'
    id = Column(Integer, primary_key=True)
    # other columns
   ```
2. **** (95% success)
   ```
   class OrderItem(Base):
    __tablename__ = 'order_items'
    order_id = Column(Integer, ForeignKey('orders.id'), primary_key=True)
    product_id = Column(Integer, primary_key=True)
   ```

## Dead Ends

- **** — Column is just a regular column; SQLAlchemy still sees no primary key. (50% fail)
- **** — Unique constraints don't satisfy the primary key requirement for ORM mapping. (80% fail)
