Bureaucrats, cc_docs_admin, cc_staff
2,318
edits
Line 49: | Line 49: | ||
# A parameterized query | # A parameterized query | ||
paste(c("INSERT INTO employee(name,age) VALUES(\"John Smith\",",toString(age),");",query),collapse='') | paste(c("INSERT INTO employee(name,age) VALUES(\"John Smith\",",toString(age),");",query),collapse='') | ||
dbExecute(dbase,query) | |||
# Close the database connection | # Close the database connection | ||
Line 63: | Line 63: | ||
int main(int argc,char** argv) | int main(int argc,char** argv) | ||
{ | { | ||
int | int age = 34; | ||
std::string query; | std::string query; | ||
sqlite3* dbase; | sqlite3* dbase; | ||
sqlite3_open("foo.sqlite",&dbase); | |||
query = "INSERT INTO employee(name,age) VALUES(\"John Smith\"," + std::to_string(age) + ");"; | query = "INSERT INTO employee(name,age) VALUES(\"John Smith\"," + std::to_string(age) + ");"; | ||
sqlite3_exec(dbase,query.c_str(),nullptr,nullptr,nullptr); | |||
sqlite3_close(dbase); | sqlite3_close(dbase); |