Lu_Wang_ENB_DBX
Databricks Employee
Databricks Employee

Summary You should be able to test your FastAPI endpoints locally. Lakebase supports direct external connections via the standard PostgreSQL wire protocol, meaning your local SQLAlchemy setup can directly query the Lakebase instance without needing to be deployed to Databricks first.
Direct Connectivity Support: Lakebase allows direct connections from local terminals, external tools (like DBeaver or pgAdmin), and local application development environments using standard PostgreSQL drivers like SQLAlchemy and psycopg2.
Authentication: When deployed, the Databricks App automatically exposes PGHOST and PGUSER and provisions a role tied to the app's service principal. For local development, you simply need to authenticate your local SQLAlchemy connection using either a Databricks OAuth token (which you can generate via the CLI/SDK) or native PostgreSQL username and password credentials.
Network Reachability: Since you have already verified that the Lakebase DNS resolves and port 5432 is reachable, you are not being blocked by workspace IP ACLs or network security settings.
Next Steps Simply ensure your local environment variables mimic what the Databricks App would inject (specifically the host and user information) and pass your generated OAuth token or database password directly into your async SQLAlchemy connection string

This blog entry has more detailed instruction on how to set up SQLAlchemy: https://www.databricks.com/blog/how-use-lakebase-transactional-data-layer-databricks-apps

View solution in original post