# sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'postgresql://user:pass@localhost:5432/db'

- **ID:** `python/sqlalchemy-invalid-database-url`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The database URL is malformed, often due to special characters in the password not being URL-encoded.

## Version Compatibility

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

## Workarounds

1. **URL-encode the password** (98% success)
   ```
   from urllib.parse import quote_plus
password = 'p@ssword!'
encoded_password = quote_plus(password)
url = f'postgresql://user:{encoded_password}@localhost:5432/db'
   ```
2. **Use a config file with properly escaped strings** (90% success)
   ```
   # In config file:
DATABASE_URL=postgresql://user:p%40ssword%21@localhost:5432/db
   ```

## Dead Ends

- **Removing special characters from the password** — This changes the credentials and may break authentication. (70% fail)
- **Using single quotes around the URL** — The URL is still invalid; the issue is with encoding. (80% fail)
