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.