From the course: Advanced Python: Practical Database Examples
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Define a database schema - Python Tutorial
From the course: Advanced Python: Practical Database Examples
Define a database schema
- [Instructor] The purpose of our API is to host book data and allow different clients to access it. The book data will live in a database. Before we can store it there we need to define the schema for what we will store about a book and how we will store it. We'll be using SQLAlchemy to create our schema and access the data in our database. Let's install it in its dependency MySQL Connector. We'll be doing this in a virtual environment so let's activate it. And we'll install MySQL Connector. We'll also install SQLAlchemy. Perfect. Now we can look at some SQLAlchemy code that defines the schema. If you're using the exercise files these are located within the books API folder in a file called database.py. SQLAlchemy is a module in Python that helps you communicate with your database. Instead of writing raw SQL statements you can declare the interactions of your application in the database in a more Pythonic way.…
Contents
-
-
-
What is an API?2m 45s
-
(Locked)
API frameworks in Python1m 29s
-
(Locked)
Set up FastAPI in a Python application4m 6s
-
(Locked)
Define a database schema2m 56s
-
(Locked)
Create a MySQL database3m 45s
-
(Locked)
Create an API contract2m 22s
-
(Locked)
Build a POST endpoint with FastAPI2m 27s
-
(Locked)
Call a new API using Postman3m 35s
-
(Locked)
Add data to a database in Python using SQLAlchemy4m 45s
-
(Locked)
Integrate a database with a FastAPI application3m 33s
-
(Locked)
Challenge: Develop a GET endpoint with FastAPI and a DB1m 35s
-
(Locked)
Solution: Develop a GET endpoint with FastAPI and a Database7m 22s
-
-
-
-