How do I execute a sql-file inside D code

Andre Pany andre at s-e-a-p.de
Tue Aug 20 13:10:55 UTC 2019


On Tuesday, 20 August 2019 at 11:33:33 UTC, Anders S wrote:
> I'm creating an application that connect to a database and 
> write data from another application. Now when I start the 
> application I want it to check if the database exists and if 
> not create the database and it's tables.
>
> I have everything working IF the database and tables exist.
>
> 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
>
> Any ideas ?

You need to use an additional library to communicate with the 
database. The library to use depends on the type of database 
(Oracle, DB2, sqlite, Hana, postgres,...)

Which database type do you target?

Kind regards
Andre


More information about the Digitalmars-d-learn mailing list