icon icon

Python + SQL – data operations and ORM (SQLAlchemy)

icon

Training process

Training needs analysis

If you have specific requirements regarding the training programme, we will carry out a training needs analysis for you. This will guide us on which aspects of the programme should receive greater emphasis, so that the training programme meets your specific needs.

What will you gain?

icon

Connect Python to PostgreSQL - You will learn how to configure a Python application to connect with PostgreSQL on your own, so you can start working with data smoothly in analytics workflows and backend projects.

icon

Run queries with psycopg - You will practice executing SQL from Python with psycopg, working with cursors, handling transactions, and catching errors, so your database code becomes safer and more reliable.

icon

Work with pandas and SQL - You will learn how to load data into DataFrames and write it back to the database after transformations, which will help you build practical reporting and data preparation workflows.

icon

Understand ORM in practice - You will see how SQLAlchemy and ORM work in real use, so you can replace manual table operations with clear class models that are easier to extend and maintain in larger projects.

icon

Model your data structure - You will learn to define models and map classes to tables, helping you organize application data more clearly and prepare a database structure for real business use cases faster.

icon

Master CRUD and filtering - You will practice inserting, reading, updating, and deleting records, along with building more advanced queries, so you can handle common data operations confidently in your application.

icon

Control schema changes - You will learn how to create and drop tables, update the schema, and approach migrations, which will help you evolve a database more safely as your application code changes over time.

icon

Improve safety and performance - You will learn best practices for connection handling, query parameterization, code organization, and optimization, helping you avoid common mistakes and improve solution stability.

Training programme

1. Introduction to working with a database in Python

At the start, the training sets the technical context for database work in Python and the client–database interaction model. It also positions psycopg and SQLAlchemy within that landscape and shows how to configure a connection to a PostgreSQL instance.

  • client–database architecture,
  • overview of tools (psycopg, SQLAlchemy),
  • configuration of the connection to the PostgreSQL database.

2. psycopg library

Using psycopg, database access is handled at the SQL and connection level rather than through an ORM abstraction. The material covers establishing connections, executing queries with cursors, controlling transactions with commit and rollback, and responding properly to runtime errors.

  • establishing a connection to the database,
  • executing SQL queries,
  • cursor handling,
  • transactions (commit, rollback),
  • error handling.

3. Working with data and pandas

For analytical workflows, pandas becomes the bridge between database content and tabular processing in Python. Participants retrieve results into pd.DataFrame, transform data before persistence, and write it back efficiently, with attention to larger data sets and execution cost.

  • retrieving data into pd.DataFrame,
  • saving data from DataFrame to the database,
  • data transformations before saving,
  • efficient work with larger data sets.

4. SQLAlchemy – introduction to ORM

SQLAlchemy introduces an ORM layer that links Python classes with relational tables. The section explains the core ORM concept, basic configuration, model definition, and how object attributes are mapped so application code can work with structured data more consistently.

  • the ORM concept,
  • SQLAlchemy configuration,
  • defining data models,
  • mapping classes to tables.

5. Database structure management

When a schema changes, table definitions must be managed in a controlled way rather than edited ad hoc. This part covers creating and dropping tables, updating the database structure, and the role of migrations as a foundation for repeatable schema evolution.

  • creating tables,
  • deleting tables,
  • schema update,
  • migrations (introduction).

6. Operations on data (CRUD)

Working directly on records, participants handle the full CRUD cycle with SQL statements executed from Python. The focus includes inserting, reading, updating, and deleting data, then extending basic operations with filtering and more complex query conditions.

  • INSERT – adding records,
  • SELECT – retrieving data,
  • UPDATE – updating records,
  • DELETE – deleting data,
  • filtering and complex queries.

7. Best practices for working with a database

Reliable database work depends on how connections, queries, and code are managed across the application. This section addresses parameterized statements for security, clearer code organization, and practical ways to improve performance through query analysis and optimization.

  • connection management,
  • security (query parameterization),
  • code organization,
  • performance and query optimization.

What are the prerequisites for participating in the training?

icon

Basic Python skills - You should be comfortable with variables, conditionals, loops, functions, and imports, so you can focus on database work instead of spending time on Python basics.

icon

Basic SQL knowledge - You should know core SQL statements such as SELECT, INSERT, UPDATE, and DELETE, because during the training you will execute and analyze database queries.

icon

Terminal and packages - You should know how to run Python scripts and install libraries with pip, so you can prepare your environment smoothly for exercises and hands-on work with the tools.

icon

Understanding tables and data - You should understand what tables, records, and columns are, so moving into model mapping, CRUD operations, and conscious work with database structures is much easier.