ND1125
ND1125

Reputation: 41

create sqlite3 db from sql statements from file in c++

I am trying to write c++ application to create sqlite db or update existing db from sql statements which are present in text file. I am not able to find right way to do. As a workaround i used system() with "cat sqlfile.txt | sqlite3 mydb FYI. I am using sqlite3 3071502

Upvotes: 1

Views: 470

Answers (1)

Validus Oculus
Validus Oculus

Reputation: 2701

You need to use STL fstream library to read the content of file. Tutorials are here: http://www.cplusplus.com/doc/tutorial/files/

After that, you need to use sqlite c++ api to execute sql commands. Tutorials are here: https://www.sqlite.org/c3ref/exec.html

Upvotes: 1

Related Questions