Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite Datatype Mapping to .net (CLR) framework datatypes

Please can any one give me some authentic information regarding data type mappings from Sqlite to .net (CLR) framework.

Regards

Umair

like image 460
Omayr Avatar asked Sep 11 '25 20:09

Omayr


1 Answers

SQLite is kind of odd (for a database) in that it uses a dynamic type system. The type is associated with the data, not the column.

From SQLite website:

Data types supported by SQLite are:

NULL. The value is a NULL value.

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8

bytes depending on the magnitude of the value.

REAL. The value is a floating point value, stored as an 8-byte IEEE

floating point number.

TEXT. The value is a text string, stored using the database encoding

(UTF-8, UTF-16BE or UTF-16LE).

BLOB. The value is a blob of data, stored exactly as it was input.

Even dates are stored as one of those types:

1.2 Date and Time Datatype

SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
REAL as Julian day numbers, the number of days since noon in Greenwich

on November 24, 4714 B.C. according to the proleptic Gregorian calendar. INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.

Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.


So SQLite associates data with one of those 5 types (including NULL) and the application is responsible for interpreting the data as something more specific (e.g. TEXT to DateTime, in the case of .NET).

like image 102
Giovanni Galbo Avatar answered Sep 13 '25 10:09

Giovanni Galbo