How do I execute a sql-file inside D code
XavierAP
n3minis-git at yahoo.es
Thu Aug 22 13:39:00 UTC 2019
On Tuesday, 20 August 2019 at 11:33:33 UTC, Anders S wrote:
>
> Use this code to check
> conn.exec("CREATE DATABASE IF NOT EXISTS boxweb;");
>
> however haven't found a way to run the sql file that create the
> tables. The file is in the source folder
I understand you're using some API to some SQL implementation
which allows you to run SQL commands from strings, but not from
files which is what you want?
Just read the file into a string with the D std lib:
import std:file;
conn.exec( readText(fileName) );
https://dlang.org/phobos/std_file.html#.readText
More information about the Digitalmars-d-learn
mailing list