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

#227: No more awaiting, async comes to SQLAlchemy

Published Wed, Mar 31, 2021, recorded Wed, Mar 31, 2021

Watch the live stream:

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

About the show

Brian #1: Number One, that's "retract plank," not "remove plank."

Michael #2: SQLAlchemy 1.4.0 Released

  • Exciting: 1st release to properly support an async API
  • Has a new select() + execute() rather than session.query() API
  • Intended to unify Core and ORM.
  • See new vs. old API compared.
  • Requires aiosqlite for async API + SQLite: conn_str = 'sqlite+aiosqlite:///filename'

Micaela #3: django-tenants

  • by Tom Turner
  • Multi-tenancy Implementation for Django (typically for SaaS websites e.g. Shopify)
  • currently on v3.2.1 (Aug 2020) release
  • Requirements: Django 2 and PostgreSQL
  • It was largely based on django-tenant-schemas library
  • Data Architecture: shared database, separate schema for each tenant
  • Domain setup / URL routing for root and per tenant:
    • Examples:
      • http://my-domain.com:8000/
      • http://tenant.my-domain.com:8000/
      • http://tenant2.my-domain.com:8000/
  • Possible Use-cases:
    • a hospital with different branches
    • restaurant franchise with different branches
  • Possible Limitations:
    • You can’t use the normal migration commands (python manage.py migrate_schemas instead of python manage.py migrate)
    • Reports - when you need to create a report regarding all the clients/tenants, tenant data will be on separate schemas
  • see also: How to get Django Tenants up and Running

Brian #5: pre-commit ci

  • pre-commit is “a framework for managing and maintaining multi-language pre-commit hooks.”
  • Hooks can be run during commits, but also hooked other events, such as merge, push, after switching branches, etc.
  • Even if you run pre-commit yourself, it’d be nice to make sure all hooks are run by people submitting pull requests.
  • pre-commit ci *is a service that “enforces that these issues are discovered (which is opt-in for each developer's workflow via *pre-commit) but also fixes the issues automatically, letting developers focus their time on more valuable problems.”

Michael #4: Snyk (Python) Package Advisor

  • via David Smit
  • Provides package health score, built up from
    • Popularity
    • Maintenance
    • Security
    • Community
  • Code of conduct and related metrics
  • Number of releases, commits, maintainers, age, etc.
  • Lots of nice graphs and ways you can contribute

Micaela #6: PyWebIO

  • by Wang Weimin
  • Allows you build simple web applications or browser-based GUI applications without the need to write HTML and JavaScript.
  • Has input and output modules
  • Based on tornado
  • Possible Use-cases:
    • Hobby projects - for people who know how to write Python code but want to do away with JavaScript
    • Could be a good teaching tool - ex. if you’re teaching kids or beginners and you want to make them appreciate the concept of input and output
  • Possible Limitation: once you need to style your HTML, it might be a bit difficult to do so since it’s tightly coupled with the Python code

Extras

Michael

Brian

  • packages: pytest-yuk, pytest-srcpaths, pytest-check

Micaela

  • Last day of March membership drive for the PSF https://twitter.com/ThePSF/status/1377000184375296003

Joke: Commenting your code


Want to go deeper? Check our projects