https://github.com/savvydatainsights/opencpu-mysql
Custom OpenCPU Docker image prepared for connecting to a MySQL database instance.
https://github.com/savvydatainsights/opencpu-mysql
docker mysql opencpu r
Last synced: 3 months ago
JSON representation
Custom OpenCPU Docker image prepared for connecting to a MySQL database instance.
- Host: GitHub
- URL: https://github.com/savvydatainsights/opencpu-mysql
- Owner: savvydatainsights
- License: mit
- Created: 2019-04-15T14:54:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T15:35:41.000Z (about 6 years ago)
- Last Synced: 2025-01-18T02:41:19.234Z (5 months ago)
- Topics: docker, mysql, opencpu, r
- Language: Dockerfile
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# opencpu-mysql
[](https://opensource.org/licenses/MIT) [](https://hub.docker.com/r/savvydatainsights/opencpu-mysql/builds) [](https://hub.docker.com/r/savvydatainsights/opencpu-mysql)
Custom OpenCPU Docker image prepared for connecting to a MySQL database instance.
## Build command
`docker build -t savvydatainsights/opencpu-mysql .`
## Requirements
[Bind mount](https://docs.docker.com/storage/bind-mounts) an [odbc.ini](odbc.ini) like the example:
```ini
[DSN]
Description=MySQL database
Driver=MySQL ODBC 8.0 Driver
SERVER=mysql
PORT=3306
DATABASE=data_analysis
UID=root
PWD=root
```The **Driver** key must have the value **MySQL ODBC 8.0 Driver**, the name defined during the MySQL connection driver installation.
The other values must be set according to the connection parameters of your MySQL instance.
## Test
Run a MySQL Docker image:
`docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=data_analysis -p 3306:3306 -d mysql:8.0.15`
Run the custom OpenCPU Docker image:
`docker run --name opencpu --link mysql:mysql -v $(pwd)/odbc.ini:/etc/odbc.ini -p 8004:8004 -d savvydatainsights/opencpu-mysql`
Enter into the OpenCPU container:
`docker exec -it opencpu bash`
Execute the command (if your odbc.ini section is other than DSN, replace it accordingly):
`isql -v DSN`
The output must be something like:
```
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
```## Compose
An alternative to run each Docker image separatedly is executing:
`docker-compose up -d`
If the Docker image doesn't exist locally, it will be built automatically. If you prefer to download it from [Docker Hub](https://hub.docker.com/r/savvydatainsights/opencpu-mysql), run before:
`docker pull savvydatainsights/opencpu-mysql`