iwongu / sqlite3pp

SQLite3++ - C++ wrapper of SQLite3 API
MIT License
609 stars 177 forks source link

how to insert a NULL value ? #68

Closed Becheler closed 1 year ago

Becheler commented 3 years ago

Hi! Thank you for this library! I wanted to know the syntax i could use to insert a NULL value in a database ? For now I insert an empty string using:

sqlite3pp::command cmd(
  this->m_database,
  "INSERT INTO table (a, b, c) VALUES (?,?,?)"
);
cmd.binder() << a << b << "";
cmd.execute();

Thank you!

iwongu commented 1 year ago

It was possible to bind nullptr using bind(), but not binder(). I just added the nullptr binding in binder(). You can do

cmd.binder() << nullptr;