# sqlalchemy.exc.NoSuchTableError: Table 'orders' not found

- **ID:** `python/sqlalchemy-missing-table-definition`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The ORM model references a table that does not exist in the database, or the metadata is not properly loaded.

## Version Compatibility

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

## Workarounds

1. **Use Base.metadata.create_all() to create missing tables** (95% success)
   ```
   from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
Base.metadata.create_all(engine)
   ```
2. **Load table metadata from the database** (90% success)
   ```
   from sqlalchemy import Table, MetaData
metadata = MetaData()
orders_table = Table('orders', metadata, autoload_with=engine)
   ```

## Dead Ends

- **Manually creating the table with raw SQL** — The ORM model may still fail if metadata is not refreshed. (65% fail)
- **Ignoring the error and proceeding** — Subsequent queries will fail with the same error. (100% fail)
