Skip to content

Feature request: sqlite-utils insert-files should be able to convert fields #597

Open

Description

@grimnight

Currently using both insert-files and convert is needed in order to create sqlar files, it would be more convenient if it could be done with just one command.

~
❯ cat test.py
import os

class Example:
    def __init__(self, arg1, arg2):
        self.arg1 = arg1

~
❯ sqlite-utils insert-files test.sqlar sqlar test.py -c name:name -c data:content -c mode:mode -c mtime:mtime -c sz:size --pk=name
  [####################################]  100%

~
❯ sqlite-utils convert test.sqlar sqlar data "zlib.compress(value)" --import=zlib --where "name = 'test.py'"
[####################################]  100%

~
❯ cat test.py | sqlite-utils convert test.sqlar sqlar data "zlib.compress(sys.stdin.buffer.read())" --import=zlib --import=sys --where "name = 'test.py'" # Alternative way
  [####################################]  100%

~
❯ sqlite3 test.sqlar "SELECT hex(data) FROM sqlar WHERE name = 'test.py';" | python3 -c "import sys, zlib; sys.stdout.buffer.write(zlib.decompress(bytes.fromhex(sys.stdin.read())))"
import os

class Example:
    def __init__(self, arg1, arg2):
        self.arg1 = arg1

~
❯ rm test.py

~
❯ sqlar -l test.sqlar
test.py

~
❯ sqlar -x test.sqlar

~
❯ cat test.py
import os

class Example:
    def __init__(self, arg1, arg2):
        self.arg1 = arg1

Activity

  1. changed the title [-]sqlite-utils insert-files should be able to convert fields[/-] [+]Feature request: sqlite-utils insert-files should be able to convert fields[/+] on Apr 5, 2024
  2. Just-Basij commented on Oct 27, 2026

    @Just-Basij

    Hi, I’ve been working on this issue and have a local solution that adds --convert and --import to insert-files. I’d like to test it a bit more before opening a PR.
    Could you assign the issue to me? I’d also appreciate any feedback or suggestions you have about this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions