rusackas commented on code in PR #26038: URL: https://github.com/apache/superset/pull/26038#discussion_r1408579248
########## docs/docs/databases/docker-add-drivers.mdx: ########## @@ -7,87 +7,57 @@ version: 1 ## Adding New Database Drivers in Docker -Superset requires a Python database driver to be installed for each additional type of database you -want to connect to. When setting up Superset locally via `docker compose`, the drivers and packages -contained in -[requirements.txt](https://github.com/apache/superset/blob/master/requirements.txt) and -[requirements-dev.txt](https://github.com/apache/superset/blob/master/requirements-dev.txt) -will be installed automatically. +Superset requires a Python database driver to be installed for each additional type of database you want to connect to. -In this section, we'll walk through how to install the MySQL connector library. The connector -library installation process is the same for all additional libraries and we'll end this section -with the recommended connector library for each database. +In this example, we'll walk through how to install the MySQL connector library. The connector library installation process is the same for all additional libraries. ### 1. Determine the driver you need -To figure out how to install the [database driver](/docs/databases/installing-database-drivers) of your choice. +Consult the [list of database drivers](/docs/databases/installing-database-drivers) and find the PyPI package needed to connect to your database. In this example, we're connecting to a MySQL database, so we'll need the `mysqlclient` connector library. -In the example, we'll walk through the process of installing a MySQL driver in Superset. +### 2. Install the driver in the container -### 2. Install MySQL Driver +We need to get the `mysqlclient` library installed into the Superset docker container (it doesn't matter if it's installed on the host machine). We could enter the running container with `docker exec -it <container_name> bash` and run `pip install mysqlclient` there, but that wouldn't persist permanently. -As we are currently running inside of a Docker container via `docker compose`, we cannot simply run -`pip install mysqlclient` on our local shell and expect the drivers to be installed within the -Docker containers for superset. +To address this, the Superset `docker compose` deployment uses the convention of a `requirements-local.txt` file. All packages listed in this file will be installed into the container from PyPI at runtime. This file will be ignored by Git for the purposes of local development. -In order to address this, the Superset `docker compose` setup comes with a mechanism for you to -install packages locally, which will be ignored by Git for the purposes of local development. Please -follow these steps: - -Create `requirements-local.txt` +Create the file `requirements-local.txt` in a subdirectory called `docker` that exists in the directory with your `docker-compose.yml` or `docker-compose-non-dev.yml` file. ``` -# From the repo root... +# Run from the repo root: touch ./docker/requirements-local.txt ``` -Add the driver selected in step above: +Add the driver identified in step above. You can use a text editor or do it from the command line like: ``` echo "mysqlclient" >> ./docker/requirements-local.txt ``` -Rebuild your local image with the new driver baked in: +**If you are running a stock (non-customized) Superset image**, you are done. Launch Superset with `docker compose -f docker-compose-non-dev.yml up` and the driver should be present. -``` -docker compose build --force-rm -``` +You can check its presence by entering the running container with `docker exec -it <container_name> bash` and running `pip freeze`. The PyPI package should be present in the printed list. -After the rebuild of the Docker images is complete (which may take a few minutes) you can relaunch using the following command: +**If you're running a customized docker image**, rebuild your local image with the new driver baked in: ``` -docker compose up +docker compose build --force-rm Review Comment: Is this part necessary, or does `docker-compose up` do effectively the same thing? -- 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]
