A personal toolkit for data malnipulation. A WIP.
- Requires Python 3.11 and up. Project uses newer constructs like structual pattern matching.
- Ensure
poetryis installed.- Since poetry is a standalone CLI app, it's preferable to not use
pip. Usepipx, a package manager, or the installer.
- Since poetry is a standalone CLI app, it's preferable to not use
cp .env.template .envand enter your configuration into the.envfile.- Alternatively, you can use environment variables.
- As of now, the most important configuration is the SQL Alchemy connection string, which specifies your target database. This is treated as a secret in the confiuration.
- REMINDER: Never commit your
.envfile to git.
- Then use
poetry installto install all project dependencies. - Finally, use
poetry run krtools --helpfor usage instructions.
See documentation in docs/. Use $ sphinx-build docs/ docs/_build to build
API reference. Currently, this has not been tested as a package, so the application is run with either
poetry run or python -m krtools.
Conceptually, this application is meant to be used with a SQL Alchemy ORM. This is an area I'm brainstorming, but I would like to get this working so you can import your organizations ORM from a package from a private registry and then supply it on the command line. The challenge here is handling multiple SQL dialects, since not all are interchangable. As of now, The tests work with both SQLite and Postgres, but I'm not using any dialect-specific features of either.
Each of these commands assume that the SQL Alchemy connection string is supplied as an env variable, either on the system on in an .env file. Otherwise, the connection string can be supplied with the --target / -t option. Be sure to know the risks of supplying sensitive secrets this way. Preferably use environment variables.
krtools sql build --schema movielens
cat tests/data/movies_test.csv | krtools sql create --schema movielens --model movie
poetry run krtools sql create --schema movielens --model movie --upsert --input-files tests/data/movies_test.csv
poetry run krtools sql create --schema movielens --model movie --upsert --input-files tests/data/