All Projects → simonw → Sqlite Transform

simonw / Sqlite Transform

Licence: apache-2.0
Tool for running transformations on columns in a SQLite database

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Sqlite Transform

Sqlcetoolbox
SQLite & SQL Server Compact Toolbox extension for Visual Studio, SSMS (and stand alone)
Stars: ✭ 651 (+2859.09%)
Mutual labels:  sqlite
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+3268.18%)
Mutual labels:  sqlite
Xorm
Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
Stars: ✭ 6,464 (+29281.82%)
Mutual labels:  sqlite
Aspnet5identityserverangularimplicitflow
OpenID Connect Code / Implicit Flow with Angular and ASP.NET Core 5 IdentityServer4
Stars: ✭ 670 (+2945.45%)
Mutual labels:  sqlite
Cloudytabs
CloudyTabs is a simple menu bar application that lists your iCloud Tabs.
Stars: ✭ 701 (+3086.36%)
Mutual labels:  sqlite
Mybb
MyBB is a free and open source forum software.
Stars: ✭ 750 (+3309.09%)
Mutual labels:  sqlite
Node Sqlite
SQLite client for Node.js applications with SQL-based migrations API written in Typescript
Stars: ✭ 642 (+2818.18%)
Mutual labels:  sqlite
Delphi Orm
Delphi ORM
Stars: ✭ 16 (-27.27%)
Mutual labels:  sqlite
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+3159.09%)
Mutual labels:  sqlite
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+3422.73%)
Mutual labels:  sqlite
Sqlancer
Detecting Logic Bugs in DBMS
Stars: ✭ 672 (+2954.55%)
Mutual labels:  sqlite
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+115454.55%)
Mutual labels:  sqlite
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+34954.55%)
Mutual labels:  sqlite
Bareos
Main repository with the code for the libraries and daemons
Stars: ✭ 651 (+2859.09%)
Mutual labels:  sqlite
Diesel
A safe, extensible ORM and Query Builder for Rust
Stars: ✭ 7,702 (+34909.09%)
Mutual labels:  sqlite
Sqlitedict
Persistent dict, backed by sqlite3 and pickle, multithread-safe.
Stars: ✭ 641 (+2813.64%)
Mutual labels:  sqlite
Weapsy
ASP.NET Core CMS
Stars: ✭ 748 (+3300%)
Mutual labels:  sqlite
Pecee Pixie
Lightweight, easy-to-use querybuilder for PHP inspired by Laravel Eloquent - but with less overhead.
Stars: ✭ 19 (-13.64%)
Mutual labels:  sqlite
Chronophore
Desktop app for tracking student sign-ins in a tutoring center.
Stars: ✭ 6 (-72.73%)
Mutual labels:  sqlite
Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+28318.18%)
Mutual labels:  sqlite

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.

jsonsplit

The jsonsplit subcommand takes columns that contain a comma-separated list, for example a tags column containing records like "trees,park,dogs" and converts it into a JSON array ["trees", "park", "dogs"].

This is useful for taking advantage of Datasette's Facet by JSON array feature.

$ sqlite-transform jsonsplit my.db mytable tags

It defaults to splitting on commas, but you can specify a different delimiter character using the --delimiter option, for example:

$ sqlite-transform jsonsplit \
    my.db mytable tags --delimiter ';'

Values within the array will be treated as strings, so a column containing 123,552,775 will be converted into the JSON array ["123", "552", "775"].

You can specify a different type for these values using --type int or --type float, for example:

$ sqlite-transform jsonsplit \
    my.db mytable tags --type int

This will result in that column being converted into [123, 552, 775].

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

The --dry-run option will output a preview of the transformation against the first ten rows, without modifying the database.

Terminology warning

This tool uses the word "transform" to mean something different from the sqlite-utils transform command.

In sqlite-utils, "transform" is used to describe running complex alter table statements, see Executing advanced ALTER TABLE operations in SQLite

sqlite-transform uses the term to describe performing a transformation or conversion on every value in a column.

I apologize for this confusion! I wish I had used different names for these two concepts.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].