Code Self Study Forum

Interesting Python Packages

I recently came across a few Python packages that look like they could be useful. The only one I’ve used so far is click. If you know of other packages that people here might like, post a comment below.

dataset

This might be useful for quickly saving data: dataset: databases for lazy people

dataset provides a simple abstraction layer removes most direct SQL statements without the necessity for a full ORM model - essentially, databases can be used like a JSON file or NoSQL store.

  • Automatic schema : If a table or column is written that does not exist in the database, it will be created automatically.
  • Upserts : Records are either created or updated, depending on whether an existing version can be found.
  • Query helpers for simple queries such as all rows in a table or all distinct values across a set of columns.
  • Compatibility : Being built on top of SQLAlchemy, dataset works with all major databases, such as SQLite, PostgreSQL and MySQL.

pluggy

pluggy – add a plugin system to your Python programs.

It gives users the ability to extend or modify the behaviour of a host program by installing a plugin for that program. The plugin code will run as part of normal program execution, changing or enhancing certain aspects of it.

In essence, pluggy enables function hooking so you can build “pluggable” systems.

datasette

Datasette provides an instant, read-only JSON API for any SQLite database. It also provides tools for packaging the database up as a Docker container and deploying that container to hosting providers such as Zeit Now.

Got CSV data? Use csvs-to-sqlite to convert them to SQLite, then publish them with Datasette. Or try Datasette Publish, a web app that lets you upload CSV data and deploy it using Datasette without needing to install any software.

click

click – for writing command-line tools in Python.

Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box.

mongoengine is also worth checking out. It’s a quick way to save data when writing scripts:

Jeremy just told me about https://github.com/Miserlou/Zappa

Apparently, it helps manage severless web apps that are based on python (including Django and Flask)

1 Like

Here is one I learned about recently: https://xlsxwriter.readthedocs.io/
It’s for creating xlsx (Excel) files. One limitation - you can’t use it on an existing file, you need to use the lib to create the file from scratch.

Another probably better known option is: https://openpyxl.readthedocs.io/en/stable/
But last time I tried openpyxl, I couldn’t use it on files that didn’t have certain properties (because they were auto-generated by an application other than excel). There are workarounds though.

1 Like