For sqlite-utils issue 464 I implemented a fix to a tiny bug in a dependency in my own fork on GitHub. …
TIL the Python standard library struct module defaults to interpreting binary strings using the endianness of your machine. …
I tried pip-tools for the first time today to pin the requirements for the natbat/pillarpointstewards Django app. …
TLDR: Use shutil.copyfileobj(fsrc, fdst)
…
I needed to generate a grid calendar that looks like this (design by Natalie Downe): …
I wanted to produce the following output from a command-line tool: …
David Beazley on Twitter: …
Carelessly including the output of json.dumps()
in an HTML page can lead to an XSS hole, thanks to the following: …
I tried to install my datasette-bplist plugin today in a fresh Python 3.10 virtual environment on macOS and got this error: …
David Beazley on Twitter said: …
I needed to tell both flake8
and mypy
to ignore the same line of code. …
My csvs-to-sqlite README includes a section that shows the output of the csvs-to-sqlite --help
command (relevant issue). …
For complicated reasons I found myself wanting to write Python code to resolve a graph of dependencies and produce a plan for efficiently executing them, in parallel where possible. …
Pyodide provides "Python with the scientific stack, compiled to WebAssembly" - it's an incredible project which lets you run a full working Jupyter notebook, complete with complex packages such as numpy and pandas, entirely in your browser without any server-side Python component running at all. …
Inspired by this tweet by Mike Driscoll I decided to try using Fabric to run commands over SSH from a Python script, using a public key for authentication. …
For sqlite-utils issue #309 I had an error that looked like this: …
Today I discovered codespell via this Rich commit. codespell
is a really simple spell checker that can be run locally or incorporated into a CI flow. …
Today I learned how to use the Python trace module to output every single executed line of Python code in a program - useful for figuring out exactly when a crash or infinite loop happens. …
When building the --sniff option for sqlite-utils insert
(which attempts to detect the correct CSV delimiter and quote character by looking at the first 2048 bytes of a CSV file) I had the need to peek ahead in an incoming stream of data. …
Users were reporting the following error using sqlite-utils
to import some CSV files: …
PyInstaller can take a Python script and bundle it up as a standalone executable for macOS, Linux and apparently Windows too (I've not tried it on Windows yet). …
asyncio
in Python is a form of co-operative multitasking, where everything runs in a single thread but asynchronous tasks can yield to other tasks to allow them to execute. …
I had a list of Python dictionaries I wanted to output as YAML, but I wanted to control the style of the output. …
I figured out how to run a subprocess with a time limit for datasette-ripgrep, using the asyncio.create_subprocess_exec()
method. The pattern looks like this: …
sqlite-utils provides a decorator for registering custom Python functions that looks like this: …
I wanted to add a --encoding
option to sqlite-utils insert
which could be used to change the file encoding used to read the incoming CSV or TSV file - see sqlite-utils #182. …
I hit a bug today where I had defined a Click option called open
but in doing so I replaced the Python bulit-in open()
function: …
This tip is for when you are working on a Python command-line application that runs using that program's name, as opposed to typing python my_script.py
. I usually need this when I'm working on applications built using Click, e.g. projects I start using my click-app cookiecutter template. …
datasette-leaflet-geojson outputs GeoJSON geometries in HTML pages in a way that can be picked up by JavaScript and used to plot a Leaflet map. …
I needed this for the datasette install
and datasette uninstall
commands, see issue #925. …
I was researching password hashing for datasette-auth-passwords. I wanted very secure defaults that would work using the Python standard library without any extra dependencies. …
For https://github.com/simonw/datasette/issues/581 I want to be able to inspect a Python function to determine which named parameters it accepts and send only those arguments. …
First, checkout the cpython repo: …
For photos-to-sqlite I needed to install osxphotos
as a dependency, but only if the platform is macOS - it's not available for Linux. …
If you installed datasette
using pipx install datasette
you can install additional plugins with pipx inject
like so: …
I was trying to figure out the shape of the JSON object from https://github.com/simonw/coronavirus-data-gov-archive/blob/master/data_latest.json?raw=true - which is 3.2MB and heavily nested, so it's difficult to get a good feel for the shape. …
Once you have installed the "command line tools" for Catalina using the following terminal command: …
I wanted to convert a datetime object (from GitPython) to UTC without adding the pytz
dependency. …