FastAPI and SQLModel are two of the hottest new Python technologies for developing asynchronous APIs with modern Python. If you're struggling with wrapping your head around how it all works, this course is for you. Here you'll learn all the most important fundamentals for creating APIs that support all database CRUD operations for adding, editing, and deleting database tables and rows.
FastAPI and SQLModel are two of the hottest new Python technologies for developing asynchronous APIs with modern Python. If you're struggling with wrapping your head around how it all works, this course is for you. Here you'll learn all the most important fundamentals for creating APIs that support all database CRUD operations for adding, editing, and deleting database tables and rows.
The course takes a very hands-on approach. That’s because most of us learn by doing. All of the code generated in the course is also available for download, so you can use it for future reference when trying to remember how to accomplish some goal. Topics and techniques covered include:
· Creating SQLModel databases and tables
· Creating FastAPI routes and functions for posting, retrieving, updating, and deleting data
· Customizing API Request and Response Schemas
· Using RegEx validation in SQLModel
· Designing re-usable server-side validators
· Sorting and Searching with SQLModel
· Working with virtual deletes and undeletes
· Joining tables
· Customizing column names in responses
· Using HTML forms for database interactions
· Debug FastAPI and SQLModel with VS Code Breakpoints
In short, the course is all about learning how to do all the common day-to-day operations found in apps that allow users to interact with databases. All the code in the course is also available for download, and organized in a way to help students look up the code they need, on-the-fly, as-needed with minimum fuss.
Students need not already be familiar with FastAPI or SQLModel. However, students should already be familiar with basic Python programming. Some familiarity with SQL and databases also helpful.
This lesson overviews what you need to get started creating modern asynchronous APIs with Python, FastAPI, and SQLModel.
Here you'll learn how to set up a virtual environment for working with FastAPI and SQLModel.
Here you'll create a models.py file and to define the data models for your application.
Here you'll create your app's database.py file and a live SQLite database for development and testing.
Here you'll learn to use a database browser to help with testing and debugging your API.
Here you'll learn how to design an API be designing and declaring some routes and functions for database interactions.
This lesson shows how to define functions within your API to accept data from API requests, and return data in a response.
Many modern APIs accept and return data in JSON format. But sometimes it's handy to just return some HTML. This lessons shows you how and why.
As your code increases in complexity, you'll need the ability to step through the code with breakpoints. This lesson shows you how to do that using VS Code.
Here you'll learn skills for controlling exactly how your API responds to a request, and how things look in the automatic FastAPI documentation.
Once you API for posting new data is working, you can create routes for retrieving data. This lesson shows you how.
This lesson shows you how to create an API route to allow users to update data that's already in the database.
This lesson shows you how to set up and API route for physically deleting a row from a table.
FastAPI's automatic documentation is a great convenience for API developers. But it's default schemas aren't always ideal. This lesson shows you how to improve those, to better serve your API users.
Often we need the same kind of server-side validation across multiple routes and functions. This lesson provides a way to centralize those with simple Python functions, so you don't have to repeat the same over and over again throughout your routes and functions.
Putting things in alphabetical or numeric order, and performing complex queries are common tasks for developers. This lesson shows you how to do those things in FastAPI and SQLModel.
Once you've understood the basics of using routes with a simple database table, you're ready to move on to more complex data types. This lesson shows you how to add another table with a foreign key to the Category model. It also shows you how to work with Booleans and Datetimes in SQLModel.
RegEx is a great tool for validating data based on content, size, and pattern. This lesson shows you how to use RegEx for validation in your FastAPI and SQLModel models.
Once you have your new, related table defined, you can start creating routes for it. This lesson shows you how to create a route for adding rows to the Video table.
Virtual deleting allows auditors to keep track of what's been deleted in the past. It also provides the option to undelete. This lesson shows you how to set up routes for virtual deletes and undeletes.
When retrieving rows from the Videos table, you must exclude rows that have been virtually deleted. This lesson shows you how.
Our Video model includes a field to tracking when a row was last updated. This lesson shows you how to update a row, and also update the change date automatically.
There may be times when you want a route to contain data from two or more tables. This lesson shows you how to join tables so you can make that happen.
There may be times when the label you gave a table field isn't ideal for data you're returning. In this lesson you'll learn how to control the names of columns returned by your API.
Sometimes your app needs to know how many rows exist in a table. This lesson shows you how to obtain such counts within your API.
When you use FastAPI templating to return HTML, you typically need static CSS and JavaScript files, as on a standard website. This lesson shows you how to set up a folder for static files in FastAPI.
This lesson shows you how to set up a templates folder for use with Jinja2 and FastAPI templating.
If you use templates and HTML forms for your front-end, you may want to serve entire pages to each request. This lesson shows you how to set up a layout page to accomplish just that.
In this lesson you'll learn to create an HTML form for entering new rows into a database table.
Your new form can send data to your API. This lesson shows how to write the code to accept the data, and put it in the database.
In this lesson we'll add a little CSS to make the pages easier on the eyes.
Dropdown lists and other controls often need to get their date from a database upon request. This lesson shows you how to population a dropdown list with data from the Category table.
In this lesson you'll learn to copy items from a database to an HTML form that can list them on a page, with click-to-edit buttons for each row.
With the forms in place for allowing updates, you just need a route on the server side to accept those updates and persist to the database. This lesson shows you how to write that code.
When a function completes some job, such as saving new or edited data, you may want to return them to the list of items rather then the form from which they came. That's called a redirect, and this lesson shows you how to do that in FastAPI.
This lesson shows you how to allow users to delete a row (with confirmation), and how to customize each page's title. To put the finishing touches on our FastAPI templating example.
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.