MCPcopy Create free account
hub / github.com/davisking/dlib / statement

Method statement

dlib/sqlite/sqlite.h:118–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 {
117 public:
118 statement (
119 database& db_,
120 const std::string sql_statement
121 ) :
122 needs_reset(false),
123 step_status(SQLITE_DONE),
124 at_first_step(true),
125 db(db_.db),
126 stmt(0),
127 sql_string(sql_statement)
128 {
129 // make sure requires clause is not broken
130 DLIB_ASSERT(db_.is_open() == true,
131 "\t statement::statement()"
132 << "\n\t The database must be opened before calling this routine."
133 << "\n\t this: " << this
134 );
135
136 int status = sqlite3_prepare_v2(db.get(),
137 sql_string.c_str(),
138 sql_string.size()+1,
139 &stmt,
140 NULL);
141
142 if (status != SQLITE_OK)
143 {
144 sqlite3_finalize(stmt);
145 throw sqlite_error(sqlite3_errmsg(db.get()));
146 }
147 if (stmt == 0)
148 {
149 throw sqlite_error("Invalid SQL statement");
150 }
151 }
152
153 ~statement(
154 )

Callers

nothing calls this directly

Calls 4

sqlite_errorClass · 0.70
is_openMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected