Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#213: Uh oh, Vulcans have infiltrated Flask

Published Wed, Dec 23, 2020, recorded Wed, Dec 23, 2020

Sponsored by us! Support our work through:

Special guest: Anthony Shaw

Stream on YouTube as well

Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

Michael #1: Django Ledger Project

  • by Miguel Sanda
  • The mission is to provide free and open source accounting software that could easily replace commercial alternatives like QuickBooks.
  • Django Ledger supports:
    • Chart of Accounts.
    • Financial Statements (Income Statement & Balance Sheets).
    • Automatic financial ratio & insight calculations.
    • Multi tenancy.
    • Hierarchical entity management.
    • Self-contained Ledgers, Journal Entries & Transactions.
    • Financial Activities Support (operational/financial/investing).
    • Basic OFX & QFX file import.
    • Bills & Invoices with optional progressible functionality.
    • Basic navigational templates.
    • Entity administration & entity manager support.
    • Bank Accounts.
  • Not quite ready for production.
  • This project is actively looking for contributors. Any financial and/or accounting experience is a big plus. If you have prior accounting experience and want to contribute, don't hesitate to contact.
  • Browse the screenshots on the github repo.

Brian #2: Flask-Meld: simple JavaScript interactive features without all of the JavaScript.

Anthony #3: Bitwise operators in Python (RealPython)

  • Article by Bartosz Zaczyński
  • Particularly useful for the enum.IntFlag and enum.Flag classes in the stdlib since 3.7
        >>> class Color(Flag):
        ...     RED = auto()
        ...     BLUE = auto()
        ...     GREEN = auto()
        ...     WHITE = RED | BLUE | GREEN

Michael #4: Why should you use an ORM (Object Relational Mapper)?

  • You may have heard you should use an ORM, but why?
  • To get a better understanding of how ORMs work, it’s helpful to work through the kind of problems they can solve.
  • Data modeled as classes is great but has some shortcomings
    • How do you query, filter, sort it?
    • How do you store it? Classes live in memory only and pickling isn’t ideal for many reasons
    • There is also concurrency, transactional operations/atomiticity
  • Enter the DB
    • But plain SQL is error prone (did you refactor that name? oops)
    • Plain SQL has code written within another language (SQL within Python, tools help but still)
    • Plain SQL has potential security issues (unless you use parameters)
  • ORMs
    • ORMs are libraries that sit between the SQL database world and your object-oriented programming language world.
    • For all intents and purposes, they are an abstraction layer that allows, among other things, for the translation of Python to SQL.
  • A cycle is formed
    • Define our models in the Python world as objects
    • the ORM layer translates those models to SQL statements with SQL types to create tables and columns.
    • In our application, we instantiate objects from those models, which creates rows in the aforementioned tables.
    • Finally, when we want those objects back, we use Python code to retrieve them, which triggers the ORM layer to create the necessary query to retrieve the rows from the database. Then, the ORM layer takes the resulting rows and maps them back to objects.
  • And you get migrations

Brian #5: sqlite-utils: a Python library and CLI tool for building SQLite databases

  • Simon Willison, @simonw
  • sqlite-utils is a combination Python library and command-line tool I’ve been building over the past six months which aims to make creating new SQLite databases as quick and easy as possible.”
  • CLI for sqlite
    • Run queries and output JSON, CSV, or tables
    • analyzing tables
    • inserting data
    • creating, dropping, transforming tables
    • creating indexes
    • searching
  • Python API for using as a library
    • way easier interaction with sqlite.
          import sqlite_utils
          db = sqlite_utils.Database("demo_database.db")
          # This line creates a "dogs" table if one does not already exist:
              {"id": 1, "age": 4, "name": "Cleo"},
              {"id": 2, "age": 2, "name": "Pancakes"}
          ], pk="id")
  • sqlite-utils docs

Anthony #6: Online conferences are not working for me. But this was a good talk,

  • “What the struct?!” by Zachary Anglin at the Pyjamas conference.
  • Explains the struct libraries macro-language for converting binary data structures into Python native types (and vice versa)
  • Really nice if you want to programmatically edit/read binary structure (combining with the bitwise operators).
  • If you’re getting into this topic. Save-game hacking is an interesting place to start.
  • I use SynalizeIT! /Synalysis as a binary data grammar explorer. It has some example save game formats
  • Its also great for hacking/CTF.





  • From February 1 I’ll be the new Python Open Source advocate at Microsoft, working with Nina Zacharenko
  • Give us a quick update on Pyjion + .NET Core?


Want to go deeper? Check our projects