mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-10 18:44:20 +02:00
Implemented and documented sqlite-utils insert --all
This commit is contained in:
parent
f1569c9f7f
commit
e66299c6ed
3 changed files with 38 additions and 3 deletions
26
docs/cli.rst
26
docs/cli.rst
|
|
@ -876,15 +876,35 @@ If your file does not include this row, you can use the ``--no-headers`` option
|
|||
|
||||
If you do this, the table will be created with column names called ``untitled_1`` and ``untitled_2`` and so on. You can then rename them using the ``sqlite-utils transform ... --rename`` command, see :ref:`cli_transform_table`.
|
||||
|
||||
.. _cli_insert_lines:
|
||||
.. _cli_insert_unstructured:
|
||||
|
||||
Inserting newline-delimited data
|
||||
================================
|
||||
Inserting unstructured data with \-\-lines and \-\-all
|
||||
======================================================
|
||||
|
||||
If you have an unstructured file you can insert its contents into a table with a single ``line`` column containing each line from the file using ``--lines``. This can be useful if you intend to further analyze those lines using SQL string functions or :ref:`sqlite-utils convert <cli_convert>`::
|
||||
|
||||
$ sqlite-utils insert logs.db loglines logfile.log --lines
|
||||
|
||||
This will produce the following schema:
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
CREATE TABLE [loglines] (
|
||||
[line] TEXT
|
||||
);
|
||||
|
||||
You can also insert the entire contents of the file into a single column called ``all`` using ``--all``::
|
||||
|
||||
$ sqlite-utils insert content.db content file.txt --all
|
||||
|
||||
The schema here will be:
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
CREATE TABLE [content] (
|
||||
[all] TEXT
|
||||
);
|
||||
|
||||
.. _cli_insert_replace:
|
||||
|
||||
Insert-replacing data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue