# SQLITE data types and VTK - little suggestion

**URL:** <https://discourse.vtk.org/t/sqlite-data-types-and-vtk-little-suggestion/3144>\
**Category:** Development\
**Created:** [April 24, 2020, 10:22am UTC](https://discourse.vtk.org/t/sqlite-data-types-and-vtk-little-suggestion/3144 "2020-04-24T10:22:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cobo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.vtk.org/u/cobo)\
**Post date:** [April 24, 2020, 10:22am UTC](https://discourse.vtk.org/t/sqlite-data-types-and-vtk-little-suggestion/3144/1 "2020-04-24T10:22:03Z")

</div>

In the vtkSQLiteQuery class I see that the mapping of SQLITE data types to VTK data types does the following (among others):

```
SQLITE_FLOAT -> VTK_FLOAT

```

Looking further into the SQLite documentations and source codes, SQLITE\_FLOAT is just any kind of “generic floating point” data type - with SQLite being very “pragmatic” regarding data types, adapting the internal representation (integer, float, double etc.) “on the fly” to the sort of data a user wants to store.

This is a bit like the philosophy of the vtkDataArray class for example: you can use it to access all types of numeric data, and the “common base” is always “double”, even if you access a vtkFloatArray or whatever.

With this in mind I would suggest the following little improvement:

```
SQLITE_FLOAT -> VTK_DOUBLE

```

It may not hurt in many cases, but I had serious problems in other situations with geographic coordinates in the past, so I am very careful to ensure sufficient precision - and in my own software I will definitely use a vtkDoubleArray for storing data that is reported by the vtkSQLiteQuery class as being of type VTK\_FLOAT! Once you know it you can do that, but others may fall into a trap here.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [April 24, 2020, 1:52pm UTC](https://discourse.vtk.org/t/sqlite-data-types-and-vtk-little-suggestion/3144/2 "2020-04-24T13:52:14Z")

</div>

Would this change cause an issue with code already using float arrays with the class?

---

<div class="post-metadata">

**Author:** ![kit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@kit](https://discourse.vtk.org/u/kit)\
**Post date:** [July 15, 2021, 9:03am UTC](https://discourse.vtk.org/t/sqlite-data-types-and-vtk-little-suggestion/3144/3 "2021-07-15T09:03:48Z")

</div>

I have run into a similar issue with integers.

If I have a table field with large integers (say \>2^32) and I add in it to an SQLITE db using (vtkTableToSQLiteWriter) everything is fine, but when I selected the data again using vtkRowQueryToTable the integers are truncated. I believe this is because SQLITE\_INTEGER is mapped to VTK\_INT.
