We may earn an affiliate commission when you visit our partners.
Alan Simpson

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.

Read more

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.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Use fastapi and sqlmodel to create modern python apis
  • Create routes and functions for high-performance json database interactions
  • Develop a library of code for working with multiple related tables
  • Use fastapi templating to use html forms for data entry and editing

Syllabus

Introduction

This lesson overviews what you need to get started creating modern asynchronous APIs with Python, FastAPI, and SQLModel.

Create a modern API that accepts, and returns, data in JSON format
Read more

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.

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Provides a hands-on approach to learning FastAPI and SQLModel, which can be very effective for those new to these technologies and prefer learning by doing
Teaches skills for creating APIs that support database CRUD operations, which are fundamental for building applications that interact with databases
Covers topics such as sorting, searching, and joining tables, which are essential for working with complex data structures in real-world applications
Requires familiarity with basic Python programming and some knowledge of SQL and databases, which may be a barrier for absolute beginners
Includes debugging FastAPI and SQLModel with VS Code breakpoints, which is a valuable skill for identifying and resolving issues in code
Explores the use of HTML forms for database interactions, which offers a practical approach to building user interfaces for data entry and editing

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Reviews summary

Hands-on beginner fastapi and sqlmodel

According to students, this course provides a strong hands-on introduction to building APIs with FastAPI and SQLModel. Learners appreciate the practical approach and the focus on essential CRUD operations, which is fundamental for many applications. The instructor's explanations are often found to be clear, making the core concepts accessible. While it successfully covers the basics of creating APIs and database interactions, some students note that a solid understanding of Python fundamentals and possibly prior SQL knowledge is helpful, despite being labeled beginner-friendly for the specific frameworks. The inclusion of diverse topics like database interactions, validation, and templating is seen as valuable, though some feel certain areas could be explored in greater depth.
Good intro, less detail on advanced topics.
"It's a great introduction for beginners to FastAPI and SQLModel basics."
"Could use more in-depth coverage on complex topics or optimization techniques"
"The course provides a good foundation but doesn't go deep into deployment or advanced async patterns."
Concepts are presented in an easy-to-follow way.
"The instructor explains complex topics in a way that is easy to follow."
"Lectures were well-structured and easy to understand."
"I appreciated the clear explanations for each step of the process."
Teaches essential API and database tasks.
"Learned how to perform all the essential CRUD operations clearly."
"The focus on building a functional API with database interaction was very useful."
"Gives you the practical tools needed for common backend tasks."
Emphasizes learning by doing exercises.
"The hands-on coding and projects are the strongest part of the course for me"
"I learn best by doing, and this course gives plenty of practical coding examples to follow along with."
"Really helped solidify my understanding through building out the API step-by-step."
Requires a decent grasp of basic Python.
"Make sure you are comfortable with basic Python before taking this, it moves quickly assuming you know Python."
"The course assumes you have a decent grasp of Python fundamentals, maybe more than just 'basic'."
"Some sections were a bit challenging if you're not already very familiar with Python features."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Hands-On Beginner FastAPI and SQLModel with these activities:
Review Basic SQL Concepts
Reinforce your understanding of SQL fundamentals, including creating tables, inserting data, and writing basic queries, to better grasp SQLModel concepts.
Show steps
  • Review SQL syntax for SELECT, INSERT, UPDATE, and DELETE statements.
  • Practice writing SQL queries on sample databases.
  • Familiarize yourself with database normalization concepts.
Brush Up on Python Fundamentals
Strengthen your Python foundation, focusing on data structures, functions, and object-oriented programming, to facilitate a smoother learning experience with FastAPI and SQLModel.
Browse courses on Python Basics
Show steps
  • Review Python syntax and data types.
  • Practice writing functions and classes in Python.
  • Work through basic Python tutorials and exercises.
Read 'FastAPI: The Definitive Guide'
Deepen your understanding of FastAPI by exploring advanced features and best practices covered in this comprehensive guide.
View Melania on Amazon
Show steps
  • Read the book cover to cover.
  • Experiment with the code examples provided in the book.
  • Take notes on key concepts and techniques.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Build a Simple CRUD API
Solidify your knowledge by building a CRUD (Create, Read, Update, Delete) API for a simple data model using FastAPI and SQLModel.
Show steps
  • Define a data model using SQLModel.
  • Create FastAPI routes for CRUD operations.
  • Implement database interactions using SQLModel.
  • Test the API endpoints using a tool like Postman.
Write a Blog Post on FastAPI and SQLModel
Reinforce your learning by writing a blog post explaining the benefits of using FastAPI and SQLModel for building modern APIs.
Show steps
  • Choose a specific topic related to FastAPI and SQLModel.
  • Research and gather information on the chosen topic.
  • Write a clear and concise blog post explaining the topic.
  • Include code examples and illustrations to support your explanations.
Contribute to SQLModel Documentation
Deepen your understanding of SQLModel by contributing to its open-source documentation, improving clarity and providing examples.
Show steps
  • Identify areas in the SQLModel documentation that need improvement.
  • Fork the SQLModel repository on GitHub.
  • Make the necessary changes to the documentation.
  • Submit a pull request with your changes.
Read 'SQLAlchemy 2.0'
Gain a deeper understanding of the underlying database interactions by studying SQLAlchemy, the foundation upon which SQLModel is built.
View Essential SQLAlchemy on Amazon
Show steps
  • Read the book cover to cover.
  • Experiment with the code examples provided in the book.
  • Take notes on key concepts and techniques.

Career center

Learners who complete Hands-On Beginner FastAPI and SQLModel will develop knowledge and skills that may be useful to these careers:
Backend Developer
As a backend developer, you implement server-side logic to support web and mobile applications. This role involves working with databases, APIs, and frameworks to ensure smooth data flow and efficient application performance. With this course on FastAPI and SQLModel, you learn to create modern Python APIs and handle database CRUD operations, essential skills for any backend developer. The course's hands-on approach and downloadable code examples provide practical experience in building robust and scalable backend systems. By mastering FastAPI and SQLModel, you can design and implement efficient APIs for data interactions, customize API request and response schemas, and validate data effectively. The course's coverage of SQLModel databases and tables, FastAPI routes and functions, and database interactions using HTML forms helps you build a strong foundation in backend development.
API Developer
An API developer specializes in designing, building, and maintaining application programming interfaces that enable different software systems to communicate with each other. This role requires expertise in API design principles, security protocols, and data handling techniques. This course on FastAPI and SQLModel is directly applicable as it teaches you how to create modern Python APIs and manage database interactions. You will learn how to create routes and functions for posting, retrieving, updating, and deleting data, all crucial aspects of API development. The course's emphasis on customizing API request and response schemas, using RegEx validation, and sorting and searching with SQLModel helps you build efficient and secure APIs. The hands-on approach and downloadable code examples allow you to apply these skills in real-world scenarios, making you a proficient API developer.
Application Developer
An application developer creates and maintains software applications for various platforms, including web, mobile, and desktop. This role involves coding, testing, and debugging applications to meet specific user needs. This course on FastAPI and SQLModel is directly applicable to application development, as it teaches you how to create modern Python APIs and handle database CRUD operations. You will learn how to create routes and functions for posting, retrieving, updating, and deleting data, all crucial aspects of application development. The course's emphasis on customizing API request and response schemas, using RegEx validation, and designing reusable server-side validators helps you build efficient and secure applications. The hands-on approach and downloadable code examples help you apply these skills in real-world scenarios, making you a proficient application developer.
Full-Stack Developer
A full stack developer is proficient in both front-end and back-end development, handling all aspects of building and maintaining web applications. This includes designing user interfaces, implementing server-side logic, and managing databases. This course on FastAPI and SQLModel is highly beneficial for full stack developers, particularly for strengthening their back-end skills. It teaches you how to create modern Python APIs, handle database CRUD operations, and design reusable server-side validators. The course's coverage of HTML forms for database interactions, virtual deletes and undeletes, and joining tables adds to your versatility as a full stack developer. By mastering these concepts, you can efficiently manage data flow between the front-end and back-end, build robust APIs, and ensure seamless user experiences. The course's hands-on approach and downloadable code examples provide practical experience, accelerating your growth as a full stack developer.
Software Engineer
Software engineers design, develop, and test software applications, often working on complex projects that require a deep understanding of programming principles and software architecture. This course on FastAPI and SQLModel helps software engineers by providing practical skills in creating modern Python APIs and managing database interactions. The course teaches you how to create routes and functions for posting, retrieving, updating, and deleting data, all essential operations in software development. With its hands-on approach, the course provides a practical understanding of building robust and scalable APIs. By mastering FastAPI and SQLModel, you can design and implement efficient APIs for data interactions, customize API request and response schemas, and validate data effectively, enhancing your capabilities as a software engineer. The course also helps with debugging using VS Code breakpoints.
Data Engineer
Data engineers are responsible for designing, building, and maintaining the infrastructure that enables data storage, processing, and analysis. This role involves working with databases, data pipelines, and ETL processes to ensure data is accessible and reliable. This course on FastAPI and SQLModel may be useful if you are a data engineer. The course teaches you how to create modern Python APIs and manage database interactions using SQLModel. The skills you get from the course would be relevant to building data pipelines and APIs for data access. The course's coverage of sorting and searching with SQLModel, joining tables, and customizing column names in responses is particularly useful for managing and transforming data. The hands-on approach and downloadable code examples will help you apply these skills in real-world data engineering projects.
Web Developer
Web developers build and maintain websites and web applications, focusing on both front-end and back-end development. This role requires expertise in HTML, CSS, JavaScript, and server-side programming languages. This course on FastAPI and SQLModel is valuable for web developers looking to enhance their back-end skills. It teaches you how to create modern Python APIs and manage database interactions. The course's coverage of HTML forms for database interactions, virtual deletes and undeletes, and joining tables adds to your versatility as a web developer. By mastering these concepts, you can efficiently manage data flow between the front-end and back-end, build robust APIs, and ensure seamless user experiences. The course's hands-on approach and downloadable code examples provide practical experience, accelerating your growth as a web developer.
Solution Architect
A solution architect designs and oversees the implementation of technology solutions to address specific business problems. This role requires a broad understanding of various technologies, including cloud computing, databases, and application development frameworks. This course on FastAPI and SQLModel may be useful for solution architects by providing practical skills in creating modern Python APIs and managing database interactions. The course teaches you how to create routes and functions for posting, retrieving, updating, and deleting data, which are essential operations in many technology solutions. By mastering FastAPI and SQLModel, you can design and implement efficient APIs for data interactions, customize API request and response schemas, and validate data effectively, enhancing your capabilities as a solution architect. A deeper understanding of how APIs are built can lead to recommending better solutions.
DevOps Engineer
DevOps engineers bridge the gap between development and operations, automating and streamlining the software development lifecycle. This role involves working with CI/CD pipelines, cloud infrastructure, and automation tools. This course on FastAPI and SQLModel may be useful for DevOps engineers by providing practical skills in creating and deploying modern Python APIs. The course teaches you how to create routes and functions for posting, retrieving, updating, and deleting data, which can be automated as part of DevOps processes. The hands-on approach and downloadable code examples provide a foundation for integrating API development into DevOps workflows. By mastering FastAPI and SQLModel, you can design and implement efficient APIs for data interactions, customize API request and response schemas, and validate data effectively.
Technical Consultant
As a technical consultant, you use your technical expertise to advise clients on how to best use technology to meet their business needs. This involves assessing current systems, recommending improvements, and assisting with implementation. This course on FastAPI and SQLModel may be relevant as it equips you with practical skills in creating modern Python APIs and managing database interactions. This knowledge can be valuable when advising clients on how to build or improve their API infrastructure. The course's hands-on approach and coverage of various API development techniques can help you provide informed recommendations and assist with the implementation of API solutions. Having a solid grasp of FastAPI and SQLModel can enhance your credibility and effectiveness as a technical consultant.
Technical Lead
Technical leads oversee development teams, providing technical guidance and ensuring projects are completed successfully. This role requires strong technical skills, leadership abilities, and project management expertise. This course on FastAPI and SQLModel may be particularly relevant if you are a technical lead. While a technical lead may not always be directly involved in coding, understanding the technologies and frameworks your team uses is essential. This course equips you with practical skills in creating modern Python APIs and managing database interactions. This offers a high-level understanding of the technologies your team uses, facilitating better communication and decision-making, and ensuring you can provide effective guidance to your team.
Software Architect
Software architects are responsible for designing the overall structure and components of software systems, ensuring they meet performance, scalability, and security requirements. This role often requires a deep understanding of various technologies and architectural patterns. This course on FastAPI and SQLModel may be useful for software architects, it offers you practical skills in creating modern Python APIs and managing database interactions. While an architect rarely codes day to day, they should be fluent in the common tools and technologies used by developers on a team. The course teaches you how to create routes and functions for posting, retrieving, updating, and deleting data, which can inform architectural decisions. The hands-on approach gives insight into building robust APIs. By mastering FastAPI and SQLModel, you can design and implement efficient APIs for data interactions.
Database Administrator
Database administrators are responsible for managing and maintaining databases, ensuring their availability, performance, and security. This role involves tasks such as database design, backup and recovery, and performance tuning. This course on FastAPI and SQLModel may be useful for database administrators by providing insights into how applications interact with databases. Understanding how FastAPI and SQLModel are used to create APIs for database interactions can help database administrators optimize database performance and troubleshoot issues. The course's hands-on approach and coverage of SQLModel databases and tables may provide valuable context for database management tasks. The course can help you understand the perspective of application developers who interact with databases.
Data Scientist
Data scientists analyze data to extract insights and inform decision-making, often using statistical models and machine learning algorithms. While this role primarily focuses on data analysis, some data scientists also need to build APIs to access and share data. This course on FastAPI and SQLModel may be useful for data scientists who want to create APIs for data access. The course teaches you how to create modern Python APIs and manage database interactions, enabling you to build tools for accessing and sharing data insights. The course's coverage of sorting and searching with SQLModel, joining tables, and customizing column names in responses is also useful for preparing data for analysis. The hands-on approach and downloadable code examples allow you to apply these skills in real-world data science projects.
IT Manager
IT managers oversee the information technology infrastructure and resources of an organization, ensuring they align with business goals. This role involves strategic planning, budgeting, and managing IT staff. This course on FastAPI and SQLModel may be useful for IT managers by providing a better understanding of the technologies used by their development teams. While IT managers are not typically involved in coding, understanding the capabilities and limitations of FastAPI and SQLModel can help them make informed decisions about technology investments and project planning. The course can provide insights into how modern APIs are built and managed, which can be valuable for strategic IT planning and resource allocation.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Hands-On Beginner FastAPI and SQLModel.
SQLAlchemy is the foundation upon which SQLModel is built. provides a deep dive into SQLAlchemy's core concepts and features. It is useful for understanding the underlying mechanisms of SQLModel and for tackling more complex database interactions. This book is more valuable as additional reading for those who want to become experts.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

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.

Affiliate disclosure

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.

© 2016 - 2025 OpenCourser