11-08, 10:55–11:35 (US/Eastern), Winter Garden
Managing a database and synchronizing service data representation with the database can be tricky. In this talk, we’ll explore SQLAlchemy, a powerful SQL toolkit that can be used to simplify this task and also to enhance the readability and maintainability of the code. We’ll also discuss how to leverage SQLAlchemy’s Object Relational Mapper (ORM) system and ways to introduce some optimizations.
This talk is for developers of any level who write applications that interact with databases and want to learn how to leverage a tool like SQLAlchemy to seamlessly interact with their database and manage their data in a Pythonic way.
I’ll start by introducing SQLAlchemy and providing an overview of the toolkit and its components. Next, we’ll go step-by-step with examples to demonstrate a sample service that initially uses raw SQL text. I’ll then show how to convert this service to make use of SQLAlchemy, and then introduce ORMs to eliminate such raw SQL queries. Finally, we’ll discuss some optimizations.
Participants in this session will have learned how to:
- Use SQLAlchemy for database operations in Python, in order to make the code more readable and maintainable
- Build Python classes (ORMs) that represent the database tables
- Execute different types of queries with ORMs using SQLAlchemy’s expression language
- Experiment with different relationship-loading techniques to improve querying performance and solve the N+1 problem
No previous knowledge expected
Rhythm Patel is a software engineer at Bloomberg. He is a one of the leaders of Bloomberg's Python Guild, which is dedicated to aiding Python engineers, fostering innovation, creating and maintaining Python packages, as well as acting as a bridge to the wider Python community. Rhythm has spoken at PyCon DE & PyData Berlin 2024, PyCon US 2024, PyCon Italy 2024, PyData London 2024, and internal events. When he’s not working, you can find him playing football or tennis, traveling and hiking, or volunteering at London’s Royal Parks and London Zoo.