Introduction to the Django ORM
The Django ORM acts as a middleware between Python and the data in the database. It is a tool that comes built into Django projects, and Nautobot is a Python Django project. The ORM provides an object-oriented method to interact with relational databases. The two supported database types for Nautobot are Postgres and MySQL. Nautobot packages ORM utilities to interact with both Postgres and MySQL in the same fashion.
The Python API for the ORM allows you to perform all of the actions that would be associated with create, read, update, delete (CRUD) operations on the data in Nautobot.
The ORM is different from what we’ve seen so far. Let’s compare it with pynautobot
, which we looked at in Chapter 9.
When creating a location with pynautobot
, we must use the following code:
import pynautobotnautobot = pynautobot.api( url="https://demo.nautobot.com", token="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...