restdefense.blogg.se

Psycopg2 python postgresql tutorial
Psycopg2 python postgresql tutorial










psycopg2 python postgresql tutorial psycopg2 python postgresql tutorial

These ORMs also have tools to make the connections or relations between tables or entities. And the value of that attribute could be, e.g. With an ORM, you normally create a class that represents a table in a SQL database, each attribute of the class represents a column, with a name and a type.įor example a class Pet could represent a SQL table pets.Īnd each instance object of that class represents a row in the database.įor example an object orion_cat (an instance of Pet) could have an attribute orion_cat.type, for the column type.

#PSYCOPG2 PYTHON POSTGRESQL TUTORIAL CODE#

ORMs ¶įastAPI works with any database and any style of library to talk to the database.Ī common pattern is to use an "ORM": an "object-relational mapping" library.Īn ORM has tools to convert (" map") between objects in code and database tables (" relations"). The FastAPI specific code is as small as always.

psycopg2 python postgresql tutorial

Notice that most of the code is the standard SQLAlchemy code you would use with any framework. OAuth2 with Password (and hashing), Bearer with JWT tokensĬreate SQLAlchemy models from the Base classĬreate Pydantic models / schemas for reading / returningĬustom Response - HTML, Stream, File, othersĪlternatives, Inspiration and Comparisons Dependencies in path operation decorators












Psycopg2 python postgresql tutorial