6 ms·
I'm curious, how do you achieve a strongly-typed database with sqlite? sqlite's lack of verifying that your data fits in your defined schema is by far my bigge
by mort96 5y ago
I'm curious, how do you achieve a strongly-typed database with sqlite?
sqlite's lack of verifying that your data fits in your defined schema is by far my biggest problem with sqlite.
- ElectricalUnion 5y agocheck (typeof(column) = 'integer')
- dotancohen 5y agoSQLite has a powerful data-validation function for each column, look for CHECK Constraints: https://www.sqlite.org/lang_createtable.html https://www.sqlite.org/lang_createtable.html But the real nice thing is that SQLite will allow spreadsheet-like behaviour by allowing one to enter an invalid data type. I could check that in Python or I can store it and warn "Invalid type blah blah blah". This will make life easier for those coming from a spreadsheet, or importing data. As the program matures, I can reevaluate what to do with invalid data as a default and what options to give the user. Additionally, because SQLite allows arbitrary data in any column, adding support for e.g. formulae is greatly simplified.
- simonw 5y agoSQLite fixed that a few releases ago with STRICT tables: https://www.sqlite.org/stricttables.html https://www.sqlite.org/stricttables.html