Skip to main content

Tool for running transformations on columns in a SQLite database.

Project description

sqlite-transform

PyPI CircleCI 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='return 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:

$ 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='return "\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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sqlite_transform-0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlite_transform-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.9

File hashes

Hashes for sqlite_transform-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a87c91639a51ecc4baae4ed94c0075063b1dffec9b694011da6d4bb7dc09f5c
MD5 25e85660bbac54f8a767105095932346
BLAKE2b-256 a62e586adb881a208db21e386e7f51c07c4129d4f29a8b26089a44b906466733

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