1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-21 07:58:02 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Dylan Irlbeck
777e3fca52 Merge 5365e75267 into e91b163571 2024-06-20 03:04:38 +00:00
jbranchaud
e91b163571 Add Echo A Message From A SQL File as a MySQL TIL 2024-05-31 10:07:23 -05:00
Dylan Irlbeck
5365e75267 Update git show TIL 2020-04-29 22:17:44 -05:00
3 changed files with 37 additions and 4 deletions

View File

@@ -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)

View File

@@ -2,16 +2,16 @@
Sometimes you want to view a file on another branch (without switching Sometimes you want to view a file on another branch (without switching
branches). That is, you want to view the version of that file as it exists branches). That is, you want to view the version of that file as it exists
on that branch. `git show` can help. If your branch is named `my_feature` and on that branch. `git show` can help. If the other branch is named `some_branch` and
the file you want to see is `app/models/users.rb`, then your command should the file you want to see is `app/models/users.rb`, then your command should
look like this: look like this:
``` ```
$ git show my_feature:app/models/users.rb $ git show some_branch:app/models/users.rb
``` ```
You can even tab-complete the filename as you type it out. You can even tab-complete the filename as you type it out.
See `man git-show` for more details. See `man git-show` for more details.
[source](http://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches) [source](https://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches)

View 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 *
* *
*****************************************
```