Skip to content

Commit 108a3d1

Browse files
committed
chore add to dev.sh CLI mysql prompt into db container task
Instead of using an external MariaDB/MySQL client, we can use the container's internal mysql client directly. Since it's a container for development, and WordPress instance expects only one database, we can assume that this won't do anything in other contexts.
1 parent 1b16e3f commit 108a3d1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dev.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function _show_help {
2929
echo " nginx <args...> Execute a 'nginx' command in the 'Portal' container. All <args...> are passed to nginx."
3030
echo ""
3131
echo " Database:"
32+
echo " db Enter 'mysql' client CLI to the default database to make queries."
3233
echo " db-shell Start a shell on the 'database' container."
3334
echo " db-dump <database> Dump to standard output the <database> database of the 'database' container."
3435
echo " db-execute <database> Execute the SQL script from standard input on the <database> database of the 'database' container."
@@ -118,6 +119,19 @@ function wp-cli {
118119
_docker_compose exec -w /var/www/html portal wp "$@"
119120
}
120121

122+
function db {
123+
database="$1"
124+
if [[ -z "$database" ]]; then
125+
database="climatedata"
126+
fi
127+
echo "Connecting to MySQL '${database}' database. This should only work in development mode"
128+
echo ""
129+
echo " Reminder: to exit, use CTRL+D key combination"
130+
echo ""
131+
132+
_docker_compose exec -it db mysql -p'root' "$database"
133+
}
134+
121135
function db-shell {
122136
_docker_compose exec -it db bash
123137
}

0 commit comments

Comments
 (0)