PyCon India 2025

Understanding Plugin Architecture for Python Packages with SQLAlchemy Dialects
2025-09-14 , Track 3

Ever wondered how we do a pip install for a custom dialect in SQLAlchemy and it's create_engine is automagically able to decode the corresponding engine through the protocol declared in the connection URI ? In this talk we will uncover how plugin functionality works in Python by exploring SQLAlchemy's dialect plugins and how you can use similar methods for creating your own pluggable python package.


  1. A quick look at SQLAlchemy dialects [7m]
    - Explaining the concept of "dialects" in SQLAlchemy: Each database backend (e.g., PostgreSQL, MySQL, SQLite) is supported through a dialect. These dialects determine how SQLAlchemy communicates with various databases.
    - Highlighting how dialects allow SQLAlchemy to work seamlessly with different databases by specifying backend-specific behavior, like query translation and connection management.
    - Highlight how this has allowed SQLAlchemy to stay extensible despite newer databases being released frequently.

  2. Exploring create_engine [3m]
    - Give a quick walkthrough of relevant code parts from SQLAlchemy codebase that give an idea about how create_engine is working.

  3. Python package entrypoints [3m]
    - How setup.py entrypoints can be configured to tell information about your package to other packages.
    - How entrypoints can be defined in pyproject.toml as well

  4. Exploring importlib.metadata [2m]
    - How we can read the information shared by other packages

  5. The hello world python package [2m]
    - Create a dummy python package that creates a cli that writes "Hello world!" in the language specified by --language argument.

  6. Creating plugin structure and loader utils [5m]
    - Setup base framework for allowing loading of language plugins

  7. Extending hello world python package with hello-world-kannada-plugin [3m]
    - Create a plugin package based on the plugin spec defined for hello-world plugins
    - Install it and demonstrate how now users can print "Hello world!" in kannada too !

  8. Conclusion [2m]
    - Summarize how plugin structure can enable creating massively extensible plugins.


Prerequisites

Plugins, SQLALchemy ( good to have )

Target Audience

Intermediate