I am trying to build a small rails app to teach SQL to beginners in a game format. Part of it is a command line where the user tries to solve problems with SQL. On the backend I’d like to run their SQL command against a test database, and check the result to see if their command was correct.
My current idea is to create SQLite databases for each stage of the lesson, and then create a copy of that database for each user when they reach that stage.
I think that will work but I am concerned about efficiency.
My question is whether there is an efficient way to have users run SQL commands (including drop
, alter
, etc.), get the result, but not actually make any changes to the db itself, in essence a dry run of arbitrary SQL commands. I am familiar with SQLite and Postgres but am open to other databases.