Reputation: 2496
I am trying to migrate to SQLite. In my C++ program I use unsigned int key
to store id's. When I serialize data from C++ program to SQLite and then unserialize it back or browse the database, I see negative values (signed) in the column.
I bind unsigned ints
on serialization with this function:
sqlite3_bind_int(stmt, 1, key);
Table column for keys is declared as INT
while creation. Maybe here is my mistake?
Any suggestion how to correctly serialize unsigned ints
into SQLite and load it back without changes?
Upvotes: 2
Views: 830
Reputation: 91035
SQLite's type system doesn't support unsigned integers. But you can use sqlite3_bind_int64
instead: unsigned int
(assuming it's 32-bit) can be losslessly converted to int64_t
.
Upvotes: 3