mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Use REAL not FLOAT as SQLite column type (#680)
* Use REAL not FLOAT as SQLite column type, refs #645 * Fix for REAL columns by CSV --detect-types Refs https://github.com/simonw/sqlite-utils/issues/645#issuecomment-3568947189 * Removed note about strict and REAL
This commit is contained in:
parent
fb93452ea8
commit
c872d27bb3
9 changed files with 61 additions and 37 deletions
|
|
@ -44,7 +44,7 @@ from .utils import (
|
|||
|
||||
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||
|
||||
VALID_COLUMN_TYPES = ("INTEGER", "TEXT", "FLOAT", "BLOB")
|
||||
VALID_COLUMN_TYPES = ("INTEGER", "TEXT", "FLOAT", "REAL", "BLOB")
|
||||
|
||||
UNICODE_ERROR = """
|
||||
{}
|
||||
|
|
@ -419,7 +419,7 @@ def dump(path, load_extension):
|
|||
@click.argument(
|
||||
"col_type",
|
||||
type=click.Choice(
|
||||
["integer", "int", "float", "text", "str", "blob", "bytes"],
|
||||
["integer", "int", "float", "real", "text", "str", "blob", "bytes"],
|
||||
case_sensitive=False,
|
||||
),
|
||||
required=False,
|
||||
|
|
@ -2425,10 +2425,12 @@ def schema(
|
|||
"--type",
|
||||
type=(
|
||||
str,
|
||||
click.Choice(["INTEGER", "TEXT", "FLOAT", "BLOB"], case_sensitive=False),
|
||||
click.Choice(
|
||||
["INTEGER", "TEXT", "FLOAT", "REAL", "BLOB"], case_sensitive=False
|
||||
),
|
||||
),
|
||||
multiple=True,
|
||||
help="Change column type to INTEGER, TEXT, FLOAT or BLOB",
|
||||
help="Change column type to INTEGER, TEXT, FLOAT, REAL or BLOB",
|
||||
)
|
||||
@click.option("--drop", type=str, multiple=True, help="Drop this column")
|
||||
@click.option(
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class Default:
|
|||
DEFAULT = Default()
|
||||
|
||||
COLUMN_TYPE_MAPPING = {
|
||||
float: "FLOAT",
|
||||
float: "REAL",
|
||||
int: "INTEGER",
|
||||
bool: "INTEGER",
|
||||
str: "TEXT",
|
||||
|
|
@ -203,19 +203,21 @@ COLUMN_TYPE_MAPPING = {
|
|||
datetime.date: "TEXT",
|
||||
datetime.time: "TEXT",
|
||||
datetime.timedelta: "TEXT",
|
||||
decimal.Decimal: "FLOAT",
|
||||
decimal.Decimal: "REAL",
|
||||
None.__class__: "TEXT",
|
||||
uuid.UUID: "TEXT",
|
||||
# SQLite explicit types
|
||||
"TEXT": "TEXT",
|
||||
"INTEGER": "INTEGER",
|
||||
"FLOAT": "FLOAT",
|
||||
"REAL": "REAL",
|
||||
"BLOB": "BLOB",
|
||||
"text": "TEXT",
|
||||
"str": "TEXT",
|
||||
"integer": "INTEGER",
|
||||
"int": "INTEGER",
|
||||
"float": "FLOAT",
|
||||
"float": "REAL",
|
||||
"real": "REAL",
|
||||
"blob": "BLOB",
|
||||
"bytes": "BLOB",
|
||||
}
|
||||
|
|
@ -232,9 +234,9 @@ if np:
|
|||
np.uint16: "INTEGER",
|
||||
np.uint32: "INTEGER",
|
||||
np.uint64: "INTEGER",
|
||||
np.float16: "FLOAT",
|
||||
np.float32: "FLOAT",
|
||||
np.float64: "FLOAT",
|
||||
np.float16: "REAL",
|
||||
np.float32: "REAL",
|
||||
np.float64: "REAL",
|
||||
}
|
||||
)
|
||||
except AttributeError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue