SQL / C++ Tutorial using sqlwrapped
6. Changing data
PreviousNextIndex
Use execute() and an update sql query to change data in your database.
To enable error logging, create a class that implements the pure virtual
class IError. The sqlwrapped libraries come with two derived classes,
StderrLog and SysLog, that logs to stderr resp. syslog. The following
example has been complemented with logging to stderr.
example
int main()
{
StderrLog log;
Database db("localhost", "root", "", "tutorialdb", &log); // MySQL specific
if (!db.Connected())
{
printf("Database not connected - exiting\n");
exit(-1);
}
Query q(db);
q.execute("update player set name='Lorangrym' where num=1");
}
example4_mysql.cppexample4_sqlite3.cpp
PreviousNext