dosubot[bot] commented on issue #30187:
URL: https://github.com/apache/superset/issues/30187#issuecomment-2336813639
<!-- Answer -->
Adding the `SQLALCHEMY_DATABASE_URI` to `superset_config.py` is a good step,
but it seems the connection is still not being established automatically. Here
are a few things to check:
1. **Ensure `superset_config.py` is Loaded**: Make sure that your
`superset_config.py` file is in the PYTHONPATH and is being correctly loaded by
Superset. You can verify this by adding a print statement or logging in the
`superset_config.py` to confirm it is being executed.
2. **Database Initialization**: Superset requires the database to be
initialized. Ensure that the initialization commands are run after the
containers are up. You can add the following commands to your Docker setup to
initialize the database:
```sh
superset db upgrade
superset init
```
3. **Environment Variables in Docker**: If you are using Docker, ensure that
the environment variables are correctly set in the Docker environment. You can
add the environment variable directly in your Dockerfile or Docker Compose file.
4. **Check for Errors**: Look at the Superset logs for any errors related to
database connections. This can provide more insight into why the connection is
not being established automatically.
Here is an example of how you might modify your Docker Compose file to
include the initialization steps:
```yaml
version: '3'
services:
superset5:
build:
context: ./superset
dockerfile: dockerfile
container_name: superset5
environment:
- ADMIN_USERNAME=admin
- [email protected]
- ADMIN_PASSWORD=admin
- SUPERSET_SECRET_KEY=super_ssecret
-
SQLALCHEMY_DATABASE_URI=postgresql://superset:superset_password@postgres:5432/superset_db
ports:
- '8088:8088'
depends_on:
- postgres
command: >
/bin/bash -c "
superset db upgrade &&
superset init &&
superset run -p 8088 --with-threads --reload --debugger
"
postgres:
image: postgres:14
container_name: postgres
environment:
POSTGRES_USER: superset
POSTGRES_PASSWORD: superset_password
POSTGRES_DB: superset_db
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
volumes:
postgres_data:
```
This setup ensures that the database is upgraded and initialized before
Superset starts running.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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]