sql - Sqlite API boolean access -
This should be an easy question for me, but I did not know where it is surprisingly, so I posted I am doing it here.
I inherited an escalit-driven database in which it contains boolean columns, has been declared as such:
create table example (ex_col BOOLEAN NOT NULL DEFAULT 0,);
This table is trying to access via sqlite3c API call sqlite_column _ *
function, now given that the scalites are actually boolean types Does not support, what is the expected behavior here?
It looks like sqlite_column_int ()
always returns 0 or false , I believe this because all the columns in the Sqlite are actually text columns. ..
And what is the correct way to keep it - to get it in the form of text and then string in comparison to the truth? I do not really want to modify the database and all other code attached to it.
In an obvious way it will be "declared" in the form of a "full" column, and then when you INSERT will update or you will pass it 1 (True) or 0 (False). In this way, you maintain compatibility with C language. You do not even need to declare it as an int, just make sure you always round it up and you'll be fine.
You said that this is a legacy database, how did they first? If they are stored in the form of text, then you may need to call sqlite_column_text ()
and then a string match for the "true" or "false" verbatim string may be required.
Comments
Post a Comment