0

I am new in Mysql so excuse me for missing some relevant points during the explanation. Well, I would like to create some scripts.sql and then just call them by another main script to setup a database. Example:

  • script1.sql
  • script2.sql
  • script3.sql

Inside script_main.sql I would like to do the following code:

SELECT @scripts_path := 'C:\where\my\scripts\are';

SOURCE @scripts_path + '\script1.sql';
SOURCE @scripts_path + '\script2.sql';
SOURCE @scripts_path + '\script2.sql';

However, seems like I am declaring the scripts_path wrongly because it is returning:

C:wheremyscriptsare

Without slashes. I am wondering if there is some specif command to handle paths variables properly in mysql. I know I can use environment variables, but if there is no option I have to go with it.

3
  • Does this answer your question? How do I use "mysql source" command with a mysql variable? Commented Jun 6, 2020 at 16:40
  • "Impossible" is a hard word in programming, isn't? Well, I think I will keep searching. Commented Jun 6, 2020 at 17:52
  • No it is the reality especially the part where is says server and client are different, when you understand that you understand why it can't work. Commented Jun 6, 2020 at 18:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.