question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sqlite-utils insert: options for column types

See original GitHub issue

The insert command currently results in string types for every column - at least when used against CSV or TSV inputs.

It would be useful if you could do the following:

  • automatically detects the column types based on eg the first 1000 records
  • explicitly state the rule for specific columns

--detect-types could work for the former - or it could do that by default and allow opt-out using --no-detect-types

For specific columns maybe this:

sqlite-utils insert db.db images images.tsv \
  --tsv \
  -c id int \
  -c score float

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Feb 12, 2021

If -c isn’t available, maybe -t or --type would work for specifying column types:

sqlite-utils insert db.db images images.tsv \
  --tsv \
  --type id int \
  --type score float

or

sqlite-utils insert db.db images images.tsv \
  --tsv \
  -t id int \
  -t score float
0reactions
eyeseastcommented, Mar 15, 2022

Just ran into this issue last night. I have a big table that’s mostly numbers, but also a zip code column in a state where ZIP codes start with 0. Would be great to run something like this:

sqlite-utils insert data.db places file.csv --csv --detect-types --type zipcode text

Maybe I’ll take a crack at this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sqlite_utils Python library - sqlite-utils - Datasette
Using this factory function allows you to set Table configuration options. ... Each column is paired with a Python type indicating the type...
Read more >
sqlite-utils(1) - Debian Manpages
The SQLite ALTER TABLE statement is limited. It can add and drop columns and rename tables, but it cannot change column types, change...
Read more >
What's new in sqlite-utils 3.20 and 3.21: --lines, --text, --convert
The sqlite-utils insert command inserts rows into a SQLite database from a JSON, CSV or TSV file, creating a table with the necessary...
Read more >
Command Line Shell For SQLite
Type in SQL statements (terminated by a semicolon), press "Enter" and the SQL ... The "--wrap N" option (where N is an integer)...
Read more >
Golang SQLite database/sql - Earthly Blog
SQLite, Data Types, and database/sql. You may notice that I'm storing time as DATETIME whereas sqlite-utils suggested TEXT for that column.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found