Skip to main content

Chapter 4. Models

📄️ Defining Models

So far we have been interacting with a SQLite database directly via the standard sqlite3 module. We could do the same for other database engines such as MySQL or PostgreSQL, to give a few examples, via the pymysql and pg8000 modules. However, Django provides its own API to talk to a database, known as Django ORM. This API aims to abstract the diversity of SQL dialects into a common language using Python classes and functions. Thus, you will no longer be working with SQL code directly, unless it is a very specific query that the Django API is not able to generate, which is rare.