mirror of
https://github.com/jbranchaud/til
synced 2026-01-21 07:58:02 +00:00
Compare commits
3 Commits
2808b39828
...
88e7f399b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88e7f399b1 | ||
|
|
e91b163571 | ||
|
|
15337dfd71 |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1433 TILs and counting..._
|
_1434 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -607,6 +607,7 @@ _1433 TILs and counting..._
|
|||||||
- [Display Output In A Vertical Format](mysql/display-output-in-a-vertical-format.md)
|
- [Display Output In A Vertical Format](mysql/display-output-in-a-vertical-format.md)
|
||||||
- [Doing Date Math](mysql/doing-date-math.md)
|
- [Doing Date Math](mysql/doing-date-math.md)
|
||||||
- [Dump A Database To A File](mysql/dump-a-database-to-a-file.md)
|
- [Dump A Database To A File](mysql/dump-a-database-to-a-file.md)
|
||||||
|
- [Echo A Message From A SQL File](mysql/echo-a-message-from-a-sql-file.md)
|
||||||
- [Ignore Duplicates When Inserting Records](mysql/ignore-duplicates-when-inserting-records.md)
|
- [Ignore Duplicates When Inserting Records](mysql/ignore-duplicates-when-inserting-records.md)
|
||||||
- [List Databases And Tables](mysql/list-databases-and-tables.md)
|
- [List Databases And Tables](mysql/list-databases-and-tables.md)
|
||||||
- [Run Statements In A Transaction](mysql/run-statements-in-a-transaction.md)
|
- [Run Statements In A Transaction](mysql/run-statements-in-a-transaction.md)
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ version from my `.tool-versions` file with a step that uses `set-output`.
|
|||||||
- name: Read Node.js version to install from `.tool-versions`
|
- name: Read Node.js version to install from `.tool-versions`
|
||||||
id: nodejs
|
id: nodejs
|
||||||
run: >-
|
run: >-
|
||||||
echo "::set-output name=NODE_VERSION::$(
|
echo "NODE_VERSION=$(
|
||||||
cat .tool-versions |
|
cat .tool-versions |
|
||||||
grep nodejs |
|
grep nodejs |
|
||||||
sed 's/nodejs \(.*\)$/\1/'
|
sed 's/nodejs \(.*\)$/\1/'
|
||||||
)"
|
)" >> $GITHUB_OUTPUT
|
||||||
```
|
```
|
||||||
|
|
||||||
`echo` runs the command in the string which sets `NODE_VERSION` as an output
|
`echo` runs the command in the string which sets `NODE_VERSION` as an output
|
||||||
@@ -45,4 +45,4 @@ This output value can be referenced in a later step.
|
|||||||
`steps` has a reference to the `nodejs` step (note the `id` above) which then
|
`steps` has a reference to the `nodejs` step (note the `id` above) which then
|
||||||
has `outputs` like the `NODE_VERSION`.
|
has `outputs` like the `NODE_VERSION`.
|
||||||
|
|
||||||
[source](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#using-workflow-commands-to-access-toolkit-functions)
|
[source](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)
|
||||||
|
|||||||
32
mysql/echo-a-message-from-a-sql-file.md
Normal file
32
mysql/echo-a-message-from-a-sql-file.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Echo A Message From A SQL File
|
||||||
|
|
||||||
|
Let's say we have a SQL file that we run to seed our database. We want to echo
|
||||||
|
a message to stdout at the beginning of that file's execution. We can do this
|
||||||
|
with [a MySQL client _shell
|
||||||
|
command_](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-commands.html).
|
||||||
|
Specifically, we need to use the `\system` or `\!` command to run our system's
|
||||||
|
`echo` command.
|
||||||
|
|
||||||
|
Here is what that could look like:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
\! echo '*****************************************'
|
||||||
|
\! echo '* *'
|
||||||
|
\! echo '* Loading seed data into the database *'
|
||||||
|
\! echo '* *'
|
||||||
|
\! echo '*****************************************'
|
||||||
|
|
||||||
|
insert into products ...
|
||||||
|
```
|
||||||
|
|
||||||
|
That message banner will be output when you run the script.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ mysql -h ::1 -P 3306 -u root -D local_database < seed_data.sql
|
||||||
|
|
||||||
|
*****************************************
|
||||||
|
* *
|
||||||
|
* Loading seed data into the database *
|
||||||
|
* *
|
||||||
|
*****************************************
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user