Object-Relational Mapping: From Database to Python, and Back

This course covers the essentials of ORM in Python, an approach which allows the programmer to write transportable, scalable code.

It also covers the potential pitfalls of naïve over-use of ORM layers, and what alternatives can be deployed.


This course is suitable for tech analysts and S&T analysts (optionally).

Learning Outcomes

By the end of the course, participants will be able to:

  • Query databases in two ways:
    • Using a custom SQL query
    • Via an ORM layer and pulling the query results into Python
  • Make informed decisions about the value (and sometimes pitfalls) of working with ORM layers instead of direct database calls based on performance, query complexity and other factors


Course Content

  • Why use an ORM layer?
  • System prerequisites for working with databases in Python: install pymysql
  • Usernames, passwords and ports
  • Writing and outputting a simple query using the pymysql library
  • Critique: can we do it better?
  • Introducing SQLAlchemy for Python
  • Python vs. SQL syntax for queries
  • Incorporating into an object framework: getters, setters, wrappers
  • Paginating query results
  • Workshop: write your SQL queries in python and pull the results into pandas
  • Pitfalls of naïve ORM usage: table lock-up and other performance hits


of our clients would recommend Alpha to a colleague or peer


of a cohort was promoted within 2 years after participating in an Alpha course.


of participants felt more confident in their role, following an Alpha commercial leadership course.

Why study with Alpha?

Innovation and creativity born from experience

We are thought leaders in instructional and learning journey design and holistic solution architects. We have extensive finance and investments experience combined with skills application to deliver performance improving results. We develop immersive learning environments that maximize time to productivity, support talent retention and added value to improving quality of hires.

Knowledge Exchange Evangelists

We are focused on mining the embedded organisational intellectual capital for the benefit of the next generation. We create and curate best in class practice gathered from our experience with the leading financial institutions. We design our programmes with the end in mind – what results are you trying to achieve with this intervention? What metrics will we set ourselves to achieve that?

Generation Proof

Quality and innovation, using current market and industry best practices, have made us a trusted partner in delivering dynamic and motivating training for the financial and capital markets. Our programmes are generation proof and responsive to evolving learner needs and styles. Our solutions use a multi-stakeholder engagement strategy that expands beyond relationships between the learner and learning provider. We create connections with managers, peers and the wider business to drive impactful return on investment..

Enquire now

"*" indicates required fields

This form collects your contact information so that we can correspond with you.
Check out our privacy policy for more information about how we protect and manage your data.
This field is for validation purposes and should be left unchanged.
The team are so friendly and pleasant to work with, everyone is very professional and keen to help us. Building a relationship over the past couple of years helps us to feel like the Alpha team are even more able to understand our needs and provide more proactive solutions.
Find out more about our in-house training courses