You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/changelog.rst
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Unreleased
10
10
----------
11
11
12
12
- The ``table.insert_all()`` and ``table.upsert_all()`` methods can now accept an iterator of lists or tuples as an alternative to dictionaries. The first item should be a list/tuple of column names. See :ref:`python_api_insert_lists` for details. (:issue:`672`)
13
+
- **Breaking change:** The default floating point column type has been changed from ``FLOAT`` to ``REAL``, which is the correct SQLite type for floating point values. This affects auto-detected columns when inserting data. You can still explicitly specify ``"FLOAT"`` or ``"float"`` as a column type for backwards compatibility. (:issue:`645`)
Copy file name to clipboardExpand all lines: docs/cli.rst
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1247,7 +1247,7 @@ To stop inserting after a specified number of records - useful for getting a fas
1247
1247
1248
1248
A progress bar is displayed when inserting data from a file. You can hide the progress bar using the ``--silent`` option.
1249
1249
1250
-
By default every column inserted from a CSV or TSV file will be of type ``TEXT``. To automatically detect column types - resulting in a mix of ``TEXT``, ``INTEGER`` and ``FLOAT`` columns, use the ``--detect-types`` option (or its shortcut ``-d``).
1250
+
By default every column inserted from a CSV or TSV file will be of type ``TEXT``. To automatically detect column types - resulting in a mix of ``TEXT``, ``INTEGER`` and ``REAL`` columns, use the ``--detect-types`` option (or its shortcut ``-d``).
1251
1251
1252
1252
For example, given a ``creatures.csv`` file containing this:
1253
1253
@@ -1274,7 +1274,7 @@ Will produce this schema:
1274
1274
CREATE TABLE "creatures" (
1275
1275
"name" TEXT,
1276
1276
"age" INTEGER,
1277
-
"weight" FLOAT
1277
+
"weight" REAL
1278
1278
);
1279
1279
1280
1280
You can set the ``SQLITE_UTILS_DETECT_TYPES`` environment variable if you want ``--detect-types`` to be the default behavior:
@@ -1589,7 +1589,7 @@ This will result in the following schema:
1589
1589
CREATE TABLE "images" (
1590
1590
"path" TEXT PRIMARY KEY,
1591
1591
"md5" TEXT,
1592
-
"mtime" FLOAT
1592
+
"mtime" REAL
1593
1593
);
1594
1594
1595
1595
Note that there's no ``content`` column here at all - if you specify custom columns using ``-c`` you need to include ``-c content`` to create that column.
@@ -1888,8 +1888,8 @@ The type of the returned values will be taken into account when creating the new
1888
1888
1889
1889
CREATE TABLE "places" (
1890
1890
"location" TEXT,
1891
-
"latitude" FLOAT,
1892
-
"longitude" FLOAT
1891
+
"latitude" REAL,
1892
+
"longitude" REAL
1893
1893
);
1894
1894
1895
1895
The code function can also return ``None``, in which case its output will be ignored. You can drop the original column at the end of the operation by adding ``--drop``.
Copy file name to clipboardExpand all lines: docs/python-api.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -548,7 +548,7 @@ This will create a table with the following schema:
548
548
"id" INTEGER PRIMARY KEY,
549
549
"name" TEXT,
550
550
"age" INTEGER,
551
-
"weight" FLOAT
551
+
"weight" REAL
552
552
)
553
553
554
554
.. _python_api_explicit_create:
@@ -1271,11 +1271,11 @@ You can specify the ``col_type`` argument either using a SQLite type as a string
1271
1271
1272
1272
The ``col_type`` is optional - if you omit it the type of ``TEXT`` will be used.
1273
1273
1274
-
SQLite types you can specify are ``"TEXT"``, ``"INTEGER"``, ``"FLOAT"`` or ``"BLOB"``.
1274
+
SQLite types you can specify are ``"TEXT"``, ``"INTEGER"``, ``"FLOAT"``, ``"REAL"`` or ``"BLOB"``.
1275
1275
1276
1276
If you pass a Python type, it will be mapped to SQLite types as shown here::
1277
1277
1278
-
float: "FLOAT"
1278
+
float: "REAL"
1279
1279
int: "INTEGER"
1280
1280
bool: "INTEGER"
1281
1281
str: "TEXT"
@@ -1294,12 +1294,12 @@ If you pass a Python type, it will be mapped to SQLite types as shown here::
1294
1294
np.uint16: "INTEGER"
1295
1295
np.uint32: "INTEGER"
1296
1296
np.uint64: "INTEGER"
1297
-
np.float16: "FLOAT"
1298
-
np.float32: "FLOAT"
1299
-
np.float64: "FLOAT"
1297
+
np.float16: "REAL"
1298
+
np.float32: "REAL"
1299
+
np.float64: "REAL"
1300
1300
1301
1301
.. note::
1302
-
In sqlite-utils 3.x ``FLOAT`` is used for floating point columns when the correct column type is actually ``REAL``. If you specify ``strict=True`` tables created in strict mode will use the correct column type of ``REAL`` instead. We plan to change this behavior in ``sqlite-utils`` 4.x to always use ``REAL``, but this will represent a minor breaking change and so is being held for the next major release, see issue :issue:`645`.
1302
+
In sqlite-utils 4.0 the default floating point column type was changed from ``FLOAT`` to ``REAL``, which is the correct SQLite type for floating point columns. You can still explicitly specify ``"FLOAT"`` or ``"float"`` as a column type for backwards compatibility, but auto-detected floating point columns will now use ``REAL``. See issue :issue:`645`.
1303
1303
1304
1304
You can also add a column that is a foreign key reference to another table using the ``fk`` parameter:
0 commit comments