{"id":49687,"date":"2024-12-04T07:03:14","date_gmt":"2024-12-04T07:03:14","guid":{"rendered":"https:\/\/accuweb.cloud\/resource\/?post_type=faq&#038;p=49687"},"modified":"2026-02-17T13:40:15","modified_gmt":"2026-02-17T13:40:15","slug":"fastapi-with-relational-database-on-ubuntu","status":"publish","type":"faq","link":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu","title":{"rendered":"How to use FastAPI with a Relational Database on Ubuntu OS?"},"content":{"rendered":"<h2 class=\"ack-h2\">How to Use FastAPI with a Relational Database on Ubuntu on AccuWeb.Cloud?<\/h2>\n<p>FastAPI is a powerful and highly performant <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/application\/python-hosting\" target=\"_blank\" rel=\"noopener\">Python<\/a> web framework for creating APIs. With PostgreSQL and Fastapi, developers can create high-effectiveness web applications with a light structure. In this tutorial, we will guide you through setting up a FastAPI, connecting it to a <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\/postgresql-hosting\" target=\"_blank\" rel=\"noopener\">PostgreSQL database<\/a>, and deploying it on a Ubuntu server, hosted on AccuWeb.Cloud.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/main-1.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49699 size-full\" title=\"FastAPI with a Relational Database on Ubuntu\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/main-1.png\" alt=\"FastAPI with a relational DB on Ubuntu\" width=\"649\" height=\"649\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/main-1.png 649w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/main-1-300x300.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/main-1-150x150.png 150w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/a><\/p>\n<h3 class=\"ack-h3\">Introduction to FastAPI<\/h3>\n<p>FastAPI is a Python-based framework designed to build APIs quickly with minimal effort. It is built on Starlette (for web parts) and Pydantic (for data validation), allowing developers to use modern Python objects such as type hints, asynchronous programming, and automatic documentation generation.<br \/>\nOne of FastAPI&#8217;s key advantages is its speed. By benchmarks, FastAPI is one of the fastest web tools available. It tends to perform better than frameworks like Flask and Django in terms of <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/performance-new\" target=\"_blank\" rel=\"noopener\">performance<\/a>. Another important benefit is the automatic generation of OpenAPI documentation, which makes it easier for developers to test and interact with APIs during development.<\/p>\n<h3 class=\"ack-h3\">Setting Up an Ubuntu Server on AccuWeb.Cloud<\/h3>\n<p><b>Step 1:<\/b> Log in to your <b>AccuWeb.Cloud dashboard<\/b> and create a new virtual private server (VPS).<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1.png\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49700 size-full\" title=\"Create a new VPS\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1.png\" alt=\"Create a new VPS\" width=\"1037\" height=\"346\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1.png 1037w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1-300x100.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1-1024x342.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-1-768x256.png 768w\" sizes=\"(max-width: 1037px) 100vw, 1037px\" \/><\/a><b>Step 2:<\/b>Select <b>Ubuntu 20.04<\/b> or the latest version as your operating system and <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\" target=\"_blank\" rel=\"noopener\">database<\/a> server as a <b>PostgreSQL<\/b>.<br \/>\n<b><\/b><\/p>\n<p><b>Step 3: <\/b>Choose the appropriate resources for your server based on your needs and enter the environment name.<br \/>\n<b><\/b><\/p>\n<p><b>Step 4: <\/b>After configuring the server, click on the <b>Create<\/b> button.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2.png\"><img decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49701 size-full\" title=\"Configuring the server\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2.png\" alt=\"Configuring the server\" width=\"1224\" height=\"758\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2.png 1224w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2-300x186.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2-1024x634.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4-2-768x476.png 768w\" sizes=\"(max-width: 1224px) 100vw, 1224px\" \/><\/a><\/p>\n<h3 class=\"ack-h3\">Accessing the Server via Web SSH<\/h3>\n<p>AccuWeb.Cloud offers a convenient Web SSH feature. You don&#8217;t need a terminal <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/applications\" target=\"_blank\" rel=\"noopener\">application<\/a> on your computer for SSH access. After your server is created, you&#8217;ll see the option to access your server via <b>Web SSH<\/b> in your AccuWeb.Cloud dashboard. Click on the <b>Web SSH<\/b> button.<br \/>\nYou are now logged in to your Ubuntu server.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49702 size-full\" title=\"Web SSH\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1.png\" alt=\"Web SSH\" width=\"1138\" height=\"552\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1.png 1138w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1-300x146.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1-1024x497.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-4.1-1-768x373.png 768w\" sizes=\"(max-width: 1138px) 100vw, 1138px\" \/><\/a><\/p>\n<h3 class=\"ack-h3\">Installing Necessary Software on Ubuntu<\/h3>\n<p>Now that you have access to the Ubuntu server, it&#8217;s time to install the necessary software for our FastAPI project.<\/p>\n<h4 class=\"ack-h4\">Updating Ubuntu<\/h4>\n<p>First, update your system to ensure all existing software packages are up to date. Run the following commands:<\/p>\n<pre><code class=\"language-javascript\"><b>sudo apt update &amp;&amp; sudo apt upgrade -y<\/b><\/code><\/pre>\n<h4><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49703 size-full\" title=\"Updating Ubuntu\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu.png\" alt=\"Updating Ubuntu\" width=\"1122\" height=\"712\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu.png 1122w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu-300x190.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu-1024x650.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Updating-Ubuntu-768x487.png 768w\" sizes=\"(max-width: 1122px) 100vw, 1122px\" \/><\/a><\/h4>\n<h4 class=\"ack-h4\">Installing Python 3, pip, and Virtual Environment<\/h4>\n<p>FastAPI requires Python 3. Install it along with pip (Python&#8217;s package manager) and the virtual env tool to create isolated environments for your <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/application\/python-hosting\" target=\"_blank\" rel=\"noopener\">Python<\/a> applications:<\/p>\n<pre><code class=\"language-javascript\"><b>sudo apt install python3 python3-pip python3-venv -y --fix-missing<\/b><\/code><\/pre>\n<h4><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49704 size-full\" title=\"Installing Python\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment.png\" alt=\"Installing Python\" width=\"1299\" height=\"711\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment.png 1299w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment-300x164.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment-1024x560.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Installing-Python-3-pip-and-Virtual-Environment-768x420.png 768w\" sizes=\"(max-width: 1299px) 100vw, 1299px\" \/><\/a><\/h4>\n<h4 class=\"ack-h4\">Install Dependencies for FastAPI<\/h4>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<p>Next, install FastAPI and Uvicorn, which is the ASGI server required to run FastAPI applications:<\/p>\n<pre><code class=\"language-javascript\"><b>pip install fastapi uvicorn<\/b><\/code><\/pre>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49705 size-full\" title=\"Install dependencies for FastAPI\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI.png\" alt=\"Install dependencies for FastAPI\" width=\"1174\" height=\"710\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI.png 1174w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI-300x181.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI-1024x619.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Install-Dependencies-for-FastAPI-768x464.png 768w\" sizes=\"(max-width: 1174px) 100vw, 1174px\" \/><\/a><\/p>\n<p>To connect to PostgreSQL, you&#8217;ll also need the psycopg2 library:<\/p>\n<pre><code class=\"language-javascript\"><b>pip install psycopg2<\/b><\/code><\/pre>\n<h3 class=\"ack-h3\">Setting Up PostgreSQL Database<\/h3>\n<p>To interact with the database, we&#8217;ll need to create a new database and user in PostgreSQL. You should receive the <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\/postgresql-hosting\" target=\"_blank\" rel=\"noopener\">PostgreSQL Database<\/a> login details in the email.<br \/>\n<b>Step 1:<\/b> Log in with your PostgreSQL <b>username<\/b> and <b>password<\/b>.<br \/>\n<b><\/b><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49706 size-full\" title=\"Log in to PostgreSQL\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2.png\" alt=\"Log in to PostgreSQL\" width=\"1176\" height=\"513\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2.png 1176w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2-300x131.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2-1024x447.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-1-2-768x335.png 768w\" sizes=\"(max-width: 1176px) 100vw, 1176px\" \/><\/a><\/p>\n<p><b>Step 2:<\/b> On the left-hand side, click on the PostgreSQL server where you want to create the database.<br \/>\n<b><\/b><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49707 size-full\" title=\"PostgreSQL server\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1.png\" alt=\"PostgreSQL server\" width=\"1686\" height=\"631\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1.png 1686w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1-300x112.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1-1024x383.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1-768x287.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-2-1-1536x575.png 1536w\" sizes=\"(max-width: 1686px) 100vw, 1686px\" \/><\/a><\/p>\n<p><b>Step 3:<\/b> At the bottom of the phpPgAdmin interface, click on the &#8220;<strong>Create Database<\/strong>&#8221; link.<br \/>\n<b><\/b><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49708 size-full\" title=\"Create Database\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1.png\" alt=\"Create Database\" width=\"1359\" height=\"604\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1.png 1359w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1-300x133.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1-1024x455.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-3-1-768x341.png 768w\" sizes=\"(max-width: 1359px) 100vw, 1359px\" \/><\/a><\/p>\n<p><b>Step 4:<\/b> Fill in Database Details:<\/p>\n<ul class=\"ack-ul\">\n<li><b>Database Name:<\/b> Enter a name for your new database (e.g., my_new_database).<\/li>\n<li><b>Encoding: <\/b>Choose the character encoding for your database (e.g., UTF-8).<\/li>\n<li><b>Template:<\/b> Leave it as template1 unless you have a specific template to use.<\/li>\n<li>Other fields can typically be left as default.<\/li>\n<\/ul>\n<p><b>Step 5:<\/b> Press the &#8220;<b>Create<\/b>&#8221; button to finalize database creation.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49709 size-full\" title=\"Finalize database creation\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1.png\" alt=\"Finalize database creation\" width=\"1350\" height=\"669\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1.png 1350w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1-300x149.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1-1024x507.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Step-5-1-768x381.png 768w\" sizes=\"(max-width: 1350px) 100vw, 1350px\" \/><\/a><\/p>\n<h3 class=\"ack-h3\">Creating a FastAPI Application<\/h3>\n<p>Now that we&#8217;ve set up PostgreSQL and installed the necessary dependencies, let&#8217;s create a basic FastAPI <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/applications\" target=\"_blank\" rel=\"noopener\">application<\/a>.<br \/>\n<b>Create Project Directory: <\/b>Let&#8217;s begin by creating a directory for our FastAPI project:<\/p>\n<pre><code class=\"language-javascript\"><b>mkdir fastapi_project<\/b>\r\n<b>cd fastapi_project<\/b><\/code><\/pre>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n<p><b>Create Virtual Environment: <\/b>Create a virtual environment to isolate the project&#8217;s dependencies:<\/p>\n<pre><code class=\"language-javascript\"><b>python3 -m venv venv<\/b>\r\n<b>source venv\/bin\/activate<\/b><\/code><\/pre>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49710 size-full\" title=\"Create Virtual environment\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application.png\" alt=\"Create Virtual environment\" width=\"1578\" height=\"615\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application.png 1578w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-300x117.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1024x399.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-768x299.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1536x599.png 1536w\" sizes=\"(max-width: 1578px) 100vw, 1578px\" \/><\/a><\/p>\n<p><b>Create a FastAPI Application (main.py): <\/b>Now, let&#8217;s create a simple FastAPI app. Create a main.py file in the fastapi_project directory:<\/p>\n<pre><code class=\"language-javascript\"><b>from fastapi import FastAPI\r\n<\/b><b>from pydantic import BaseModel\r\n<\/b><b>import psycopg2<\/b>\r\n<b>app = FastAPI()<\/b>\r\n<b># Database connection function\r\n<\/b><b>def get_db_connection():\r\n<\/b><b>conn = psycopg2.connect(\r\n<\/b><b>dbname=\"fastapi_db\", user=\"fastapi_user\", password=\"yourpassword\", host=\"localhost\"\r\n<\/b><b>)\r\n<\/b><b>return conn<\/b>\r\n<b># Pydantic model for input validation\r\n<\/b><b>class Item(BaseModel):\r\n<\/b><b>name: str\r\n<\/b><b>description: str<\/b>\r\n<b># Create an item\r\n<\/b><b>@app.post(\"\/items\/\")\r\n<\/b><b>def create_item(item: Item):\r\n<\/b><b>conn = get_db_connection()\r\n<\/b><b>cursor = conn.cursor()\r\n<\/b><b>cursor.execute(\r\n<\/b><b>\"INSERT INTO items (name, description) VALUES (%s, %s)\",\r\n<\/b><b>(item.name, item.description)\r\n<\/b><b>)\r\n<\/b><b>conn.commit()\r\n<\/b><b>cursor.close()\r\n<\/b><b>conn.close()\r\n<\/b><b>return {\"name\": item.name, \"description\": item.description}<\/b>\r\n<b># Get all items\r\n<\/b><b>@app.get(\"\/items\/\")\r\n<\/b><b>def read_items():\r\n<\/b><b>conn = get_db_connection()\r\n<\/b><b>cursor = conn.cursor()\r\n<\/b><b>cursor.execute(\"SELECT * FROM items\")\r\n<\/b><b>rows = cursor.fetchall()\r\n<\/b><b>cursor.close()\r\n<\/b><b>conn.close()\r\n<\/b><b>return {\"items\": rows}<\/b><\/code><\/pre>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49711 size-full\" title=\"Create a FastAPI application\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1.png\" alt=\"Create a FastAPI application\" width=\"1578\" height=\"615\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1.png 1578w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1-300x117.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1-1024x399.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1-768x299.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-a-FastAPI-Application-1-1536x599.png 1536w\" sizes=\"(max-width: 1578px) 100vw, 1578px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">Create PostgreSQL Table<\/h4>\n<p>Before testing the FastAPI app, let&#8217;s create the necessary table in PostgreSQL to store the items.<br \/>\nLog into PostgreSQL and create the items table:<br \/>\n<b>CREATE TABLE items (<\/b><br \/>\n<b>id SERIAL PRIMARY KEY,<\/b><br \/>\n<b>name VARCHAR(100),<\/b><br \/>\n<b>description TEXT<\/b><br \/>\n<b>);<\/b><\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49712 size-full\" title=\"Create PostgreSQL table\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table.png\" alt=\"Create PostgreSQL table\" width=\"1644\" height=\"555\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table.png 1644w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table-300x101.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table-1024x346.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table-768x259.png 768w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Create-PostgreSQL-Table-1536x519.png 1536w\" sizes=\"(max-width: 1644px) 100vw, 1644px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">Connecting FastAPI to PostgreSQL<\/h4>\n<p>With the PostgreSQL table in place, the next step is to ensure the FastAPI app can interact with the <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/database\" target=\"_blank\" rel=\"noopener\">database<\/a>. The code already handles the connection and querying, so there is no further configuration needed.<\/p>\n<h4 class=\"ack-h4\">Running the FastAPI Application<\/h4>\n<p>Now, let&#8217;s run the FastAPI application using Uvicorn. In your terminal, run:<br \/>\n<b>uvicorn main:app &#8211;host 0.0.0.0 &#8211;port 8000 &#8211;reload<\/b><br \/>\nThis will start the FastAPI application and make it accessible at http:\/\/your_server_ip:8000.<\/p>\n<p><a href=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application.png\"><img loading=\"lazy\" decoding=\"async\" class=\"ack-article-image aligncenter wp-image-49713 size-full\" title=\"Running the FastAPI application\" src=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application.png\" alt=\"Running the FastAPI application\" width=\"1381\" height=\"615\" srcset=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application.png 1381w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application-300x134.png 300w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application-1024x456.png 1024w, https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/12\/Running-the-FastAPI-Application-768x342.png 768w\" sizes=\"(max-width: 1381px) 100vw, 1381px\" \/><\/a><\/p>\n<h4 class=\"ack-h4\">Accessing the FastAPI Documentation<\/h4>\n<p>FastAPI automatically generates Swagger documentation, which can be accessed at:<br \/>\n<b>http:\/\/your_server_ip:8000\/docs<\/b><br \/>\nThis interactive UI allows you to test the API endpoints directly.<\/p>\n<h3 class=\"ack-h3\">Conclusion<\/h3>\n<p>By following this guide, you have successfully set up FastAPI on the Ubuntu server. You have also been able to manage your server with Web SSH, which makes things a lot simpler during management. Fast API makes it possible to give you the foundation for building scalable, <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/performance-new\" target=\"_blank\" rel=\"noopener\">high-performance<\/a>, and asynchronous web-based APIs using efficient query techniques involving your relational database.<\/p>\n<div class=\"article-space\"><\/div>\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t\n<div class=\"article-space\"><\/div>\n","protected":false},"author":1,"featured_media":52879,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","class_list":["post-49687","faq","type-faq","status-publish","has-post-thumbnail","hentry","faq_topics-fastapi-with-relational-database-on-ubuntu","faq_topics-kb","faq_topics-product-documentation","faq_topics-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.10 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FastAPI with Relational DataBase on Ubuntu: Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use FastAPI with a Relational Database on Ubuntu OS?\" \/>\n<meta property=\"og:description\" content=\"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\" \/>\n<meta property=\"og:site_name\" content=\"AccuWeb Cloud\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-17T13:40:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#article\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\"},\"author\":{\"name\":\"Jilesh Patadiya\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\"},\"headline\":\"How to use FastAPI with a Relational Database on Ubuntu OS?\",\"datePublished\":\"2024-12-04T07:03:14+00:00\",\"dateModified\":\"2026-02-17T13:40:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\"},\"wordCount\":843,\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\",\"url\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\",\"name\":\"FastAPI with Relational DataBase on Ubuntu: Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"datePublished\":\"2024-12-04T07:03:14+00:00\",\"dateModified\":\"2026-02-17T13:40:15+00:00\",\"description\":\"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.\",\"breadcrumb\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/accuweb.cloud\/resource\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use FastAPI with a Relational Database on Ubuntu OS?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"name\":\"AccuWeb Cloud\",\"description\":\"Cutting Edge Cloud Computing\",\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\",\"name\":\"AccuWeb.Cloud\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"width\":156,\"height\":87,\"caption\":\"AccuWeb.Cloud\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\",\"name\":\"Jilesh Patadiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"caption\":\"Jilesh Patadiya\"},\"description\":\"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.\",\"sameAs\":[\"https:\/\/accuweb.cloud\/resource\",\"https:\/\/www.facebook.com\/accuwebhosting\",\"https:\/\/www.instagram.com\/accuwebhosting\/\",\"https:\/\/www.linkedin.com\/company\/accuwebhosting\/\",\"https:\/\/x.com\/accuwebhosting\",\"https:\/\/www.youtube.com\/c\/Accuwebhosting\"],\"url\":\"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"FastAPI with Relational DataBase on Ubuntu: Step-by-Step Guide","description":"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu","og_locale":"en_US","og_type":"article","og_title":"How to use FastAPI with a Relational Database on Ubuntu OS?","og_description":"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.","og_url":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu","og_site_name":"AccuWeb Cloud","article_modified_time":"2026-02-17T13:40:15+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#article","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu"},"author":{"name":"Jilesh Patadiya","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58"},"headline":"How to use FastAPI with a Relational Database on Ubuntu OS?","datePublished":"2024-12-04T07:03:14+00:00","dateModified":"2026-02-17T13:40:15+00:00","mainEntityOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu"},"wordCount":843,"publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu","url":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu","name":"FastAPI with Relational DataBase on Ubuntu: Step-by-Step Guide","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/#website"},"primaryImageOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","datePublished":"2024-12-04T07:03:14+00:00","dateModified":"2026-02-17T13:40:15+00:00","description":"Learn how to set up FastAPI with a relational database on Ubuntu OS. Follow this guide for seamless integration and deployment.","breadcrumb":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#primaryimage","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/accuweb.cloud\/resource\/articles\/fastapi-with-relational-database-on-ubuntu#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/accuweb.cloud\/resource\/"},{"@type":"ListItem","position":2,"name":"How to use FastAPI with a Relational Database on Ubuntu OS?"}]},{"@type":"WebSite","@id":"https:\/\/accuweb.cloud\/resource\/#website","url":"https:\/\/accuweb.cloud\/resource\/","name":"AccuWeb Cloud","description":"Cutting Edge Cloud Computing","publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/accuweb.cloud\/resource\/#organization","name":"AccuWeb.Cloud","url":"https:\/\/accuweb.cloud\/resource\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","width":156,"height":87,"caption":"AccuWeb.Cloud"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58","name":"Jilesh Patadiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","caption":"Jilesh Patadiya"},"description":"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.","sameAs":["https:\/\/accuweb.cloud\/resource","https:\/\/www.facebook.com\/accuwebhosting","https:\/\/www.instagram.com\/accuwebhosting\/","https:\/\/www.linkedin.com\/company\/accuwebhosting\/","https:\/\/x.com\/accuwebhosting","https:\/\/www.youtube.com\/c\/Accuwebhosting"],"url":"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin"}]}},"_links":{"self":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/49687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/comments?post=49687"}],"version-history":[{"count":14,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/49687\/revisions"}],"predecessor-version":[{"id":52962,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/49687\/revisions\/52962"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media\/52879"}],"wp:attachment":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media?parent=49687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}