Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grimnight opened this issue Sep 30, 2023 · 0 comments

Comments

@grimnight
Copy link

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
@grimnight grimnight 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 Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant