Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.06 KB

echo-a-message-from-a-sql-file.md

File metadata and controls

32 lines (25 loc) · 1.06 KB

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. Specifically, we need to use the \system or \! command to run our system's echo command.

Here is what that could look like:

\! 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.

$ mysql -h ::1 -P 3306 -u root -D local_database < seed_data.sql

*****************************************
*                                       *
*  Loading seed data into the database  *
*                                       *
*****************************************