0

I'm testing a python script that requires me to manually clear and restore a fresh copy of my database for the purposes of debugging it. Basically each time the script cracks up, it breaks my database and I need a fresh copy. It would be really convenient if I could just run a sql script to so so. This is trivial except for the part when I re-import the data from a file on my machine; I can't seem to figure out how to do that within the sql script.

I can do it by clicking through the GUI as detailed here.

And I can do it by running this in the terminal

mysql -u root -p testdb < filename.sql

But what I would really like to do is to throw a line in my sql script along with my drop and create commands. Something like this

drop schema testing2;
create database  testing2;
use testing2;
some command to restore from ....\Dump20230125.sql

I read here that I could use source ....\Dump20230125.sql but mysql workbench throws a syntax error and says that "source is not valid at this position"

Is there a way to accomplish what I'm after?

neanderslob
  • 2,633
  • 6
  • 40
  • 82

0 Answers0