{"id":955,"date":"2022-12-30T15:16:00","date_gmt":"2022-12-30T09:46:00","guid":{"rendered":"https:\/\/geekpython.in\/?p=955"},"modified":"2023-08-15T15:13:20","modified_gmt":"2023-08-15T09:43:20","slug":"integrate-postgresql-database-in-python","status":"publish","type":"post","link":"https:\/\/geekpython.in\/integrate-postgresql-database-in-python","title":{"rendered":"How To Connect And Operate PostgreSQL With Python Using psycopg2 Lib"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"heading-introduction\">Introduction<\/h1>\n\n\n\n<p>Databases are used to store and manage large amounts of data in an efficient and organized manner. Databases are used in scientific research, financial analysis, and many other fields to store and analyze data. They are an essential tool for organizing and managing data in a way that is easily accessible and usable.<\/p>\n\n\n\n<p><strong>PostgreSQL<\/strong>&nbsp;is an open-source object-relational database management system. It is widely used for managing and storing large amounts of data and is known for its reliability, flexibility, and performance.<\/p>\n\n\n\n<p>In this article, you&#8217;ll learn to connect the PostgreSQL database with Python.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-pre-requisite\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-pre-requisite\"><\/a>Pre-requisite<\/h1>\n\n\n\n<p>In order to work with a PostgreSQL database and perform various operations on the data stored in the database, it is necessary to have a basic understanding of&nbsp;<strong>Structured Query Language<\/strong>&nbsp;(SQL). With a basic knowledge of SQL, you can create tables, insert and retrieve data, update and delete data, and perform other operations on the data stored in the database.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-postgresql-and-python\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-postgresql-and-python\"><\/a>PostgreSQL and Python<\/h1>\n\n\n\n<p><strong>PostgreSQL<\/strong>&nbsp;and&nbsp;<strong>Python<\/strong>&nbsp;can be used together in several ways. For example, you can use Python to connect to a PostgreSQL database and perform various operations on the data stored in the database, such as inserting, updating, or deleting data. You can also use Python to retrieve data from the database and perform analysis or other operations on the data.<\/p>\n\n\n\n<p>To use PostgreSQL with Python, you must install a library such as&nbsp;<strong>psycopg2<\/strong>, which provides a Python interface to the PostgreSQL database.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-psycopg2-lib\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-psycopg2-lib\"><\/a>Psycopg2 lib<\/h1>\n\n\n\n<p><strong>psycopg2<\/strong>&nbsp;is a popular Python library for working with PostgreSQL databases. It is a PostgreSQL adapter for Python that provides a Python interface to the PostgreSQL database.<\/p>\n\n\n\n<p>With&nbsp;<strong>psycopg2<\/strong>, you can connect to a PostgreSQL database and perform various operations on the data stored in the database, such as inserting, updating, or deleting data. You can also use&nbsp;<strong>psycopg2<\/strong>&nbsp;to retrieve data from the database and perform analysis or other operations on the data.<\/p>\n\n\n\n<p>To install the&nbsp;<code>psycopg2<\/code>&nbsp;library, you will need to use a package manager like&nbsp;<strong>pip<\/strong>. Open a terminal or command prompt window and type the following command:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:ps decode:true \">pip install psycopg2<\/pre><\/div>\n\n\n\n<p>This will install the&nbsp;<code>psycopg2<\/code>&nbsp;library and all of its dependencies.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-installing-pgadmin4\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-installing-pgadmin4\"><\/a>Installing pgAdmin4<\/h1>\n\n\n\n<p><strong>pgAdmin4<\/strong>&nbsp;is the latest version of pgAdmin, a popular web-based graphical tool for managing and developing PostgreSQL databases. It provides a user-friendly interface that allows you to create and modify databases, tables, views, and stored procedures, run SQL queries and scripts, and manage users and permissions.<\/p>\n\n\n\n<p>However, you can download and install the pgAdmin4 app for Windows and several&nbsp;<a target=\"_blank\" href=\"https:\/\/www.pgadmin.org\/download\/\" rel=\"noreferrer noopener\">other options<\/a>&nbsp;are also available for different platforms.<\/p>\n\n\n\n<p>To use pgAdmin4, you will need to install it on your machine and then launch it from the start menu or desktop shortcut. When the application opens, you will be presented with a login screen where you can enter your credentials to connect to a PostgreSQL server. Once you are connected to the server, you can use the pgAdmin interface to manage and develop your databases.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-creating-databases-and-tables-in-pgadmin4\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-creating-databases-and-tables-in-pgadmin4\"><\/a>Creating databases and tables in pgAdmin4<\/h1>\n\n\n\n<p>To create a database and table using the pgAdmin4 app, you can follow these steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Launch the pgAdmin4 app and connect to a PostgreSQL server by entering your credentials in the login screen.<\/li>\n\n\n\n<li>In the object tree on the left side of the pgAdmin4 window, right-click on the &#8220;<strong>Databases<\/strong>&#8221; node and then hover on the &#8220;<strong>Create<\/strong>&#8221; button and select &#8220;<strong>Database&#8230;<\/strong>&#8220;. In the &#8220;<strong>Database<\/strong>&#8221; dialog, enter a name for your database and click &#8220;<strong>Save<\/strong>&#8220;.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" src=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p1-1024x608.png\" alt=\"Creating the database\" class=\"wp-image-958\" srcset=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p1-1024x608.png 1024w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p1-300x178.png 300w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p1-768x456.png 768w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p1.png 1045w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To create a table within the database you just created, right-click on the database in the object tree and select &#8220;<strong>Query Tool<\/strong>&#8220;. This will open a new query window where you can enter SQL commands to create tables.<\/li>\n\n\n\n<li>In the query window, enter the SQL command to create a table. For example, you can use the following SQL command to create a simple table called &#8220;<strong>players<\/strong>&#8221; with three columns:<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:mysql decode:true \">CREATE TABLE players (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL,\n  age TEXT NOT NULL\n);<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click the &#8220;<strong>Execute<\/strong>&#8221; button in the query window to execute the SQL command and create the table.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"965\" height=\"305\" src=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p2.png\" alt=\"Creating the table\" class=\"wp-image-959\" srcset=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p2.png 965w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p2-300x95.png 300w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p2-768x243.png 768w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To view the table you just created, expand the&nbsp;<strong>database<\/strong>&nbsp;node in the object tree, expand the &#8220;<strong>Schemas<\/strong>&#8221; node, and click on the &#8220;<strong>Tables<\/strong>&#8221; node. The table you created should be listed under the &#8220;<strong>Tables<\/strong>&#8221; node. You can double-click on the table to view its contents and structure.<\/li>\n<\/ul>\n\n\n\n<p>Now your table is ready and the next part is to&nbsp;<strong>connect<\/strong>&nbsp;this database with Python and manipulate the data inside the table that was just created.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-connecting-database-with-python\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-connecting-database-with-python\"><\/a>Connecting database with Python<\/h1>\n\n\n\n<p>To connect the PostgreSQL database with Python, you will need the&nbsp;<strong>psycopg2<\/strong>&nbsp;library installed at the beginning of the article.<\/p>\n\n\n\n<p>Open your favourite code editor and create a directory and then create a&nbsp;<code>database.py<\/code>&nbsp;file inside it and write the code for connecting the database using the&nbsp;<strong><em>psycopg2<\/em><\/strong>&nbsp;library.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">import psycopg2 as pg\n\ntry:\n    conn = pg.connect(\n        host='localhost',\n        database='Pg2Py',\n        port=5432,\n        user='postgres',\n        password='*********'\n    )\n\n    cursor = conn.cursor()\n    print(\"Connection established.\")\n\nexcept Exception as err:\n    print(\"Something went wrong.\")\n    print(err)<\/pre><\/div>\n\n\n\n<p>In the code above,&nbsp;<code>psycopg2.connect()<\/code>&nbsp;function establishes a connection to the database using the specified configurations like&nbsp;<strong><em>host<\/em><\/strong>,&nbsp;<strong><em>database<\/em><\/strong>,&nbsp;<strong><em>port<\/em><\/strong>,&nbsp;<strong><em>user<\/em><\/strong>, and&nbsp;<strong><em>password.<\/em><\/strong>&nbsp;The&nbsp;<code>cursor()<\/code>&nbsp;will allow interaction with the database.<\/p>\n\n\n\n<p>The above code will try to connect with the database and if it is connected successfully then it&#8217;ll prompt a message saying &#8220;<strong>Connection established<\/strong>&#8221; otherwise it&#8217;ll prompt an error message with the error.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-fetching-data-from-the-database\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-fetching-data-from-the-database\"><\/a>Fetching data from the database<\/h1>\n\n\n\n<p>The connection to the PostgreSQL database is now established with the help of Python and the&nbsp;<code>psycopg2<\/code>&nbsp;library.<\/p>\n\n\n\n<p>Here is an example of fetching the data present inside the table in the database.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">def fetch_data():\n    cursor.execute('''SELECT * FROM players''')\n    data = cursor.fetchall()\n    return data\n\ndetails = fetch_data()\nfor row in details:\n    print(row)<\/pre><\/div>\n\n\n\n<p>In the above code, the&nbsp;<code>cursor.execute()<\/code>&nbsp;function executes the SQL query to select all the data from the table &#8220;<strong>players<\/strong>&#8221; and&nbsp;<code>cursor.fetchall()<\/code>&nbsp;fetches the data and stores it inside the&nbsp;<code>data<\/code>&nbsp;variable.<\/p>\n\n\n\n<p>In the next block of code, the data has been displayed by calling the&nbsp;<code>fetch_data<\/code>&nbsp;function.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">(2, 'Rohit Sharma', '34')\n(1, 'Virat Kohli', '33')<\/pre><\/div>\n\n\n\n<p>The above data fetched from the&nbsp;<code>Pg2Py<\/code>&nbsp;database was added manually in the table from the pgAdmin4 app.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-creating-an-entry-in-the-database\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-creating-an-entry-in-the-database\"><\/a>Creating an entry in the database<\/h1>\n\n\n\n<p>The data can be added to the database using Python. The process is very simple, you just need to execute the SQL query to insert the data.<\/p>\n\n\n\n<p>To insert the data into the database write the following code:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">def create_entry():\n    cursor.execute('''INSERT INTO players (id, name, age) \n                    VALUES (%s, %s, %s)''', (4, 'My Ex', 22))\n\n    add_data = cursor.fetchone()\n    conn.commit()\n    return add_data\n\ndata = create_entry()\nprint(data)<\/pre><\/div>\n\n\n\n<p>The&nbsp;<code>create_entry()<\/code>&nbsp;function contains the&nbsp;<code>cursor.execute()<\/code>&nbsp;function that executes the SQL query to insert the data into the &#8220;<strong>players<\/strong>&#8221; table. Here, the simple SQL statement &#8220;<code>INSERT INTO<\/code>&#8221; used will insert the values specified after the &#8220;<code>VALUES<\/code>&#8221; statement.<\/p>\n\n\n\n<p>The&nbsp;<code>%s<\/code>&nbsp;placeholders used in the above code are good practices when adding data or updating specific data. This will help you when your data is coming dynamically into your database.<\/p>\n\n\n\n<p>The&nbsp;<code>cursor.fetchone()<\/code>&nbsp;function was used to get the added data and this time the&nbsp;<code>commit()<\/code>&nbsp;function was used to&nbsp;<strong>commit the changes to the database<\/strong>. After committing the changes, the data was displayed.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">(4, 'My Ex', '22')<\/pre><\/div>\n\n\n\n<p>The above code added the data into the &#8220;<strong>players<\/strong>&#8221; table and it can be seen easily in the pgAdmin4 app. Run the SQL query&nbsp;<code>SELECT * FROM players;<\/code>&nbsp;in the query tool of the &#8220;<strong>players<\/strong>&#8221; table.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"299\" height=\"176\" src=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p3.png\" alt=\"Data added to the database\" class=\"wp-image-960\"\/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-deleting-an-entry-from-the-database\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-deleting-an-entry-from-the-database\"><\/a>Deleting an entry from the database<\/h1>\n\n\n\n<p>You can perform a deletion action to delete the specific entry in your database. To delete the specific data, you will need to use the conditional statement in the SQL query. Suppose you want to delete the player name &#8220;<strong>Lionel Messi<\/strong>&#8221; from the database, then you will need to use the condition where you will specify that this specific name has to delete.<\/p>\n\n\n\n<p>Here&#8217;s how you can perform the action using the code:<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">def delete_entry():\n    cursor.execute('''DELETE FROM players \n                    WHERE name = %s''', (\"Rohit Sharma\",))\n    conn.commit()\n    return 'Data deleted successfully'\n\ndata = delete_entry()\nprint(data)<\/pre><\/div>\n\n\n\n<p>In the above code, the &#8220;<code>DELETE FROM<\/code>&#8221; statement has been used with the &#8220;<code>WHERE<\/code>&#8221; clause that will delete the entry from the database with a name equal to the player name &#8220;<strong>Rohit Sharma<\/strong>&#8220;.<\/p>\n\n\n\n<p>Similarly, you can use other&nbsp;<strong>column<\/strong>&nbsp;names from the table to delete an entry from the database. Most developers prefer using the column name that contains unique values in the table.<\/p>\n\n\n\n<p>The value for the&nbsp;<code>WHERE<\/code>&nbsp;clause is passed as a&nbsp;<strong>tuple<\/strong>&nbsp;to the&nbsp;<code>cursor.execute()<\/code>&nbsp;because it accepts only tuple value. If you will try to pass a value other than the tuple it&#8217;ll throw you an error.<\/p>\n\n\n\n<p>Finally, the changes were committed to the database using the&nbsp;<code>conn.commit()<\/code>&nbsp;method.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">Data deleted successfully<\/pre><\/div>\n\n\n\n<p>You can see the entry in the database has been deleted.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"180\" src=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p4.png\" alt=\"Data has been deleted\" class=\"wp-image-961\" srcset=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p4.png 486w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p4-300x111.png 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-updating-an-entry\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-updating-an-entry\"><\/a>Updating an entry<\/h1>\n\n\n\n<p>The most integral part of any application is to update its existing data and of course, that updated data has to be reflected in the database. As usual, you need to run the SQL query for updating the specific entry.<\/p>\n\n\n\n<p>Here&#8217;s the Python code for updating the entry in the database.<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">def update_entry():\n    cursor.execute('''UPDATE players\n                    SET name = %s, age = %s WHERE id = %s''',\n                   ('My other ex', 21, 2))\n    conn.commit()\n    return 'Updated successfully'\n\ndata = update_entry()\nprint(data)<\/pre><\/div>\n\n\n\n<p>In the above code, a SQL query is executed using the&nbsp;<code>execute()<\/code>&nbsp;method in which the &#8220;<code>UPDATE<\/code>&#8221; statement is used to update the &#8220;<strong>players<\/strong>&#8221; table and the &#8220;<code>SET<\/code>&#8221; statement is used to set the updated values to the existing data. The &#8220;<code>WHERE<\/code>&#8221; clause is used to specify the&nbsp;<strong>ID<\/strong>&nbsp;of the data to be updated.<\/p>\n\n\n\n<p>And then the changes were committed to the database using the&nbsp;<code>commit()<\/code>&nbsp;method.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"172\" src=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p5.png\" alt=\"Updated the existing data\" class=\"wp-image-962\" srcset=\"https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p5.png 449w, https:\/\/geekpython.in\/wp-content\/uploads\/2023\/08\/p5-300x115.png 300w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/figure>\n\n\n\n<p>The existing data with an&nbsp;<strong>ID<\/strong>&nbsp;of&nbsp;<strong>2<\/strong>&nbsp;is now updated with the specified data in the Python code and is successfully reflected in the database. You might be thinking that there was no data with an ID equal to 2 before. Data with an ID equal to 2 was manually added before updating the existing data.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"heading-conclusion\"><a href=\"https:\/\/geekpython.in\/integrate-postgresql-database-in-python#heading-conclusion\"><\/a>Conclusion<\/h1>\n\n\n\n<p>The article focuses on connecting the PostgreSQL database with Python using the PostgreSQL database adapter library called&nbsp;<code>psycopg2<\/code>. However, the complete process was not executed using Python code. Fetching, creating, deleting, and inserting operations were executed with the help of SQL queries in Python.<\/p>\n\n\n\n<p>There are popular ORMs (Object Relation Mapper) available that make the complete operations done using only Python code.<\/p>\n\n\n\n<p>But this article has a mix of both Python and SQL to integrate the PostgreSQL database with Python to perform operations like updating, creating, inserting, and much more into the database by running the Python code.<\/p>\n\n\n\n<p>Let&#8217;s recall what you&#8217;ve learned:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Connecting the PostgreSQL database with Python<\/strong><\/li>\n\n\n\n<li><strong>Fetching the data from the database<\/strong><\/li>\n\n\n\n<li><strong>Creating the entry into the database<\/strong><\/li>\n\n\n\n<li><strong>Deleting the entry from the database<\/strong><\/li>\n\n\n\n<li><strong>Updating the existing entry in the database<\/strong><\/li>\n<\/ul>\n\n\n\n<p>This will help you create a connection between the database and Python.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\ud83c\udfc6<strong>Other articles you might like<\/strong><\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/contact-form-for-your-blog-get-emails-and-save-in-db-dynamically\" rel=\"noreferrer noopener\">Create a dynamic contact form having a database and Gmail connected with it<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/using-transfer-learning-for-deep-learning-model\" rel=\"noreferrer noopener\">Build a custom deep learning model using transfer learning<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/render-images-from-flask\" rel=\"noreferrer noopener\">Display dynamic and static images on the frontend using Flask<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/argparse-in-python\" rel=\"noreferrer noopener\">Build your first command line interface using Python<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/argmax-function-in-numpy-and-tensorflow\" rel=\"noreferrer noopener\">NumPy and Tensorflow have a common function<\/a>.<\/p>\n\n\n\n<p>\u2705<a target=\"_blank\" href=\"https:\/\/geekpython.in\/numpy-argmax-function-in-python\" rel=\"noreferrer noopener\">Get the maximum value from an array using NumPy<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>That&#8217;s all for now<\/strong><\/p>\n\n\n\n<p><strong>Keep Coding\u270c\u270c<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Databases are used to store and manage large amounts of data in an efficient and organized manner. Databases are used in scientific research, financial analysis, and many other fields to store and analyze data. They are an essential tool for organizing and managing data in a way that is easily accessible and usable. PostgreSQL&nbsp;is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":957,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[2,37],"tags":[38,56,12,31],"class_list":["post-955","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-database","tag-database","tag-postgresql","tag-python","tag-python3","entry","has-media"],"_links":{"self":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/comments?post=955"}],"version-history":[{"count":3,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/955\/revisions"}],"predecessor-version":[{"id":1318,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/posts\/955\/revisions\/1318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/media\/957"}],"wp:attachment":[{"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/media?parent=955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/categories?post=955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekpython.in\/wp-json\/wp\/v2\/tags?post=955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}