Skip to main content

Tool for running transformations on columns in a SQLite database.

Project description

sqlite-transform

PyPI Changelog Tests License

Tool for running transformations on columns in a SQLite database.

How to install

$ pip install sqlite-transform

parsedate and parsedatetime

These subcommands will run all values in the specified column through dateutils.parser.parse() and replace them with the result, formatted as an ISO timestamp or ISO date.

For example, if a row in the database has an opened column which contains 10/10/2019 08:10:00 PM, running the following command:

$ sqlite-transform parsedatetime my.db mytable opened

Will result in that value being replaced by 2019-10-10T20:10:00.

Using the parsedate subcommand here would result in 2019-10-10 instead.

lambda for executing your own code

The lambda subcommand lets you specify Python code which will be executed against the column.

Here's how to convert a column to uppercase:

$ sqlite-transform lambda my.db mytable mycolumn --code='str(value).upper()'

The code you provide will be compiled into a function that takes value as a single argument. You can break your function body into multiple lines, provided the last line is a return statement:

$ sqlite-transform lambda my.db mytable mycolumn --code='value = str(value)
return value.upper()'

You can also specify Python modules that should be imported and made available to your code using one or more --import options:

$ sqlite-transform lambda my.db mytable mycolumn \
    --code='"\n".join(textwrap.wrap(value, 10))' \
    --import=textwrap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlite-transform-0.3.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

sqlite_transform-0.3.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sqlite-transform-0.3.1.tar.gz.

File metadata

  • Download URL: sqlite-transform-0.3.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for sqlite-transform-0.3.1.tar.gz
Algorithm Hash digest
SHA256 eb5b975865cd62d598fe85ad4b1cd04499317a2c6b5c04d104e293e9774a057d
MD5 dc8530fe0e454aff294d4b92a088f6a7
BLAKE2b-256 8361e9411dda2cc7022c1604a1aa935a4e0079bd0f60b0592f525521165d0921

See more details on using hashes here.

File details

Details for the file sqlite_transform-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: sqlite_transform-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for sqlite_transform-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7bcdee2efb1b6481565db1a430b7b802118563fec8d9b38aa042d3afb9e552ea
MD5 1134765e0d9a8a41108b8f7ccdf51ddd
BLAKE2b-256 6d36f98fe2415b4d40eb54f446788a27c6d9c398fcedfcd789ee1e3b13bf202a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page