liang-wenjie opened a new issue, #43699:
URL: https://github.com/apache/superset/issues/43699

   ### Bug description
   
   On `master`, native SQLAlchemy dialect discovery still calls the SQLAlchemy 
1.4 `dialect.dbapi()` API. SQLAlchemy 2 native dialects expose `import_dbapi()` 
instead. The resulting `AttributeError` is caught by the broad exception 
handler, so the installed driver is silently omitted from the available 
database types.
   
   This is reproducible with MySQL:
   
   1. Install the dependencies from `master` and install `mysqlclient`.
   2. Verify `import MySQLdb` succeeds.
   3. Open **Settings > Database Connections > + Database** or request 
`/api/v1/database/available/`.
   4. MySQL is missing from the available database list.
   
   The backend logs:
   
   ```text
   Unable to load dialect <class 
'sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb'>: type object 
'MySQLDialect_mysqldb' has no attribute 'dbapi'
   ```
   
   Expected behavior: SQLAlchemy 2 dialects should be loaded through 
`import_dbapi()`, and installed engines such as MySQL should appear in the 
database connection UI.
   
   ### Screenshots/recordings
   
   Not applicable. The failure is visible in the API response and backend log.
   
   ### Environment
   
   - Superset version: master / latest-dev (`f3985d88a1`)
   - Python version: 3.12
   - SQLAlchemy version: 2.0.52
   - mysqlclient version: 2.2.8
   - Node/browser: Not applicable
   
   ### Additional context
   
   `MySQLDialect_mysqldb` reports `hasattr(dialect, "dbapi") == False` and 
`hasattr(dialect, "import_dbapi") == True`. Falling back to `dbapi()` for older 
SQLAlchemy versions preserves backward compatibility.
   
   ### Checklist
   
   - [x] I searched Superset docs and Slack and didn't find a solution.
   - [x] I searched the GitHub issue tracker and didn't find a matching bug 
report.
   - [x] I checked Superset logs and included the relevant error above.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to