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.

Allow passing a file of code to "sqlite-utils convert"

See original GitHub issue

sqlite-utils is so nice, but the ergonomics of the multiline code in kind of tough. It’s really hard (maybe impossible) to make the newlines play well with Makefiles.

it would be great to write your code fragment in a separate file and direct it into the sqlite-utils

either like

sqlite-utils convert my.db my_table my_column < custom_code.py

or

sqlite-utils convert my.db my_table my_column --custom-code=custom_code.py

Thanks, as ever, for these great tools!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Dec 10, 2021

One option: allow CODE to be a special value of - which means “read from standard input”. It’s a tiny bit of a hack but I think it would work here.

If you wanted to replace a column entirely with hyphens you would still be able to do this:

sqlite-utils convert my.db mytable col1 '"-"'
0reactions
fgreggcommented, Dec 11, 2021

wow! that’s awesome! thanks so much, @simonw!

Read more comments on GitHub >

github_iconTop Results From Across the Web

sqlite-utils command-line tool
The --convert option can be used to apply a Python conversion function to imported data before it is inserted into the database. It...
Read more >
sqlite-utils command-line tool - Datasette
The sqlite-utils memory command works similar to sqlite-utils query , but allows you to execute queries against an in-memory database.
Read more >
CLI reference - sqlite-utils
Your Python code will be passed a "row" variable representing the imported row, and can return a modified row. This example uses just...
Read more >
sqlite_utils Python library - sqlite-utils - Datasette
Database objects are constructed by passing in either a path to a file on disk or an existing SQLite3 database connection: from sqlite_utils...
Read more >
sqlite-utils documentation
You can pass multiple files to the command if you want to run joins ... can be used in the code passed to...
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