{"id":25576579,"date":"2024-02-26T02:48:12","date_gmt":"2024-02-25T21:18:12","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25576579"},"modified":"2024-02-26T02:48:12","modified_gmt":"2024-02-25T21:18:12","slug":"how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/","title":{"rendered":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide)"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e7177204e03\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e7177204e03\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#What_is_SQL\" >What is SQL?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Why_use_SQL_with_Python_and_R\" >Why use SQL with Python and R?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Python_Tutorial\" >Python Tutorial<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Creating_a_Database\" >Creating a Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Running_a_query\" >Running a query<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#SQL_with_Pandas\" >SQL with Pandas<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#R_Tutorial\" >R Tutorial<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Creating_Database\" >Creating Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#Running_Queries\" >Running Queries<\/a><\/li><\/ul><\/nav><\/div>\n<p>The world&#8217;s most popular code language for data analysis just got a little simpler. We have demonstrated simple and effective ways to run SQL queries in Python and R, especially for data analysis and database management.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_is_SQL\"><\/span><strong>What is SQL?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Structured Query Language (SQL) is the most commonly used language to perform various data analysis tasks. It is also used to maintain relational databases, e.g. adding tables, deleting values, and optimizing the database.<\/p>\n<p>A simple relational database consists of several interconnected tables, and each table consists of rows and columns. The average technology company generates millions of data points every day. A powerful and efficient storage solution is needed to be able to use data to improve existing systems or launch new products. Relational databases such as MySQL, PostgreSQL, and SQLite solve these problems by providing powerful, secure, and high-performance database management capabilities.<\/p>\n<p>Basic SQL functions<\/p>\n<ul>\n<li>Create a new table in a database<\/li>\n<li>Run a query on a database<\/li>\n<li>Retrieve data from a database<\/li>\n<li>Insert records into a database<\/li>\n<li>Update a table records in database<\/li>\n<li>Delete records from database<\/li>\n<li>Optimize any database<\/li>\n<\/ul>\n<p>SQL is a high-demand skill that will help you get any job in the tech industry. Companies like Meta, Google, and Netflix are always looking for data experts who can extract insights from SQL databases and come up with creative solutions. You can learn the basics of SQL by following the Introduction to SQL tutorial on DataCamp.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_use_SQL_with_Python_and_R\"><\/span><strong>Why use SQL with Python and R?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>SQL can help us discover business performance, understand customer behavior, and track marketing campaign success metrics. Most data analysts can perform the majority of business intelligence tasks by running SQL queries, so why do we need tools like PoweBI, Python, and R? Using SQL queries, you can know what happened in the past but you cannot predict future predictions. These tools help us better understand current performance and potential growth.<\/p>\n<p>Python and R are flexible languages \u200b\u200bthat enable professionals to run advanced statistical analysis, build machine learning models, build data APIs, and ultimately help businesses think beyond KPIs. In this tutorial, we will learn how to connect to a SQL database, populate the database, and run SQL queries using Python and R.<\/p>\n<p>Note: If you are new to SQL, follow the SQL Skills Path to understand the fundamentals of writing SQL queries.<\/p>\n<p style=\"text-align: center\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Unlock Your Coding Potential with Our Python Programming Course \u2013 Enroll Today<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Python_Tutorial\"><\/span><strong>Python Tutorial<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Python Tutorial will cover the basics of connecting to various databases (MySQL and SQLite), creating tables, adding records, running queries, and learning functions Pandas read_sql.<\/p>\n<p><strong>Configuration <\/strong><\/p>\n<p>We can connect to the database using SQLAlchemy, but in this tutorial we will use Python&#8217;s built-in SQLite3 package to run queries against the database. SQLAlchemy supports all types of databases by providing a unified API. If you want to learn more about SQLAlchemy and how it works with other databases, check out the course Introduction to Databases in Python.<\/p>\n<p>MySQL is the world&#8217;s most popular database engine and is widely used by companies such as Youtube, Paypal, LinkedIn and GitHub.Here we will learn how to connect the database. The remaining steps to use MySQL are similar to the SQLite3 package.<\/p>\n<p>First install the mysql package using &#8216;!pip install mysql&#8217;, then create the local database engine by providing your username, password and database name.<\/p>\n<p>import mysql.connector as sql<\/p>\n<p>conn = sql.connect(<br \/>\nhost=&#8221;localhost&#8221;,<br \/>\nuser=&#8221;abid&#8221;,<br \/>\npassword=&#8221;12345&#8243;,<br \/>\ndatabase=&#8221;datacamp_python&#8221;<br \/>\n)<\/p>\n<ul>\n<li>This code imports the <b>mysql.connector<\/b> module and assigns it the alias <b>sql<\/b>.<\/li>\n<li>It then establishes a connection to a MySQL database using the <b>connect()<\/b> method of the <b>sql<\/b> module.<\/li>\n<li>The <b>connect()<\/b> method takes several parameters, including the <b>host<\/b> (the server where the database is located), <b>user<\/b> (the username to connect to the database), <b>password<\/b> (the password for the user), and <b>database<\/b> (the name of the database to connect to).<\/li>\n<li>In this case, the code connects to a database named <b>datacamp_python<\/b> on the local machine using the username <b>abid<\/b> and password <b>12345<\/b>.<\/li>\n<\/ul>\n<p>Similarly, we can create or load an SQLite database using the sqlite3.connect function. SQLite is a library that implements a serverless, standalone, zero-configuration database engine. It is compatible with DataCamp Workspace, so we will use it in our project to avoid local server errors.<\/p>\n<p>import sqlite3<br \/>\nimport pandas as pd<\/p>\n<p>conn= sqlite3.connect(&#8220;datacamp_python.db&#8221;)<\/p>\n<ul>\n<li>This code imports the sqlite3 and pandas modules into Python.<\/li>\n<li>It then creates a connection to the SQLite database named &#8220;datacamp_python.db&#8221; using the connect() method of the sqlite3 module.<\/li>\n<li>The connection object is stored in the conn variable.<\/li>\n<li>This connection object can be used to execute SQL queries and interact with the database.<\/li>\n<li>The pandas module can also be used to read data from the database into a DataFrame for further analysis.<\/li>\n<\/ul>\n<h2 id=\"creating-a-database-inthi\" class=\"no-top-margin\"><span class=\"ez-toc-section\" id=\"Creating_a_Database\"><\/span><strong>Creating a Database<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this section, we will learn how to load the COVID-19 Impact on Airport Traffic dataset, licensed under CC BY-NC-SA 4.0, into our SQLite database. We will also learn how to create a table from scratch.<\/p>\n<p>The airport traffic dataset includes the percentage of traffic volume for the reporting period from February 1, 2020 to March 15, 2020. We will load the CSV file using the Pandas read_csv function, then use the to_sql function to pass the data frame into a SQLite table. The to_sql function requires a table name (String) and connects to the SQLite engine.<\/p>\n<p>data = pd.read_csv(&#8220;data\/covid_impact_on_airport_traffic.csv&#8221;)<\/p>\n<p>data.to_sql(<br \/>\n&#8216;airport&#8217;, # Name of the sql table<br \/>\nconn, # sqlite.Connection or sqlalchemy.engine.Engine<br \/>\nif_exists=&#8217;replace&#8217;<br \/>\n)<\/p>\n<p>Now we will test whether we were successful or not by running a quick SQL query. Before running the query, we need to create a cursor that helps us run the query as shown in the code block below.<\/p>\n<p style=\"text-align: center\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Unlock Your Coding Potential with Our Python Programming Course \u2013 Enroll Today<\/a><\/strong><\/p>\n<p>You can have multiple cursors on the same database in one connection. In our case, the SQL query returns three columns and five rows from the Airports table. To display the first row, we will use cursor.fetchone().<\/p>\n<p>cursor = conn.cursor()<br \/>\ncursor.execute(&#8220;&#8221;&#8221;SELECT Date, AirportName, PercentOfBaseline<br \/>\nFROM airport<br \/>\nLIMIT 5&#8243;&#8221;&#8221;)<br \/>\ncursor.fetchone()<\/p>\n<p>&gt;&gt;&gt; (&#8216;2020-04-03&#8217;, &#8216;Kingsford Smith&#8217;, 64)<\/p>\n<p class=\"p-margin\">To show the remaining of the records, we will use <code>cursor.fetchall()<\/code>. The airport dataset is loaded into the database with a few lines of code successfully.<\/p>\n<p>cursor.fetchall()<\/p>\n[(&#8216;2020-04-13&#8217;, &#8216;Kingsford Smith&#8217;, 29),<br \/>\n(&#8216;2020-07-10&#8217;, &#8216;Kingsford Smith&#8217;, 54),<br \/>\n(&#8216;2020-09-02&#8217;, &#8216;Kingsford Smith&#8217;, 18),<\/p>\n<p>(&#8216;2020-10-31&#8217;, &#8216;Kingsford Smith&#8217;, 22)]\n<p>Now learn how to create a table from scratch and populate it by adding sample values. We will create a student information table with id (integer, primary key, auto-increment), name (text), and subject (text).<\/p>\n<p>Note: The SQLite syntax is a bit different. You should review the SQLite cheat sheet to understand the SQL queries covered in this tutorial.<\/p>\n<p>cursor.execute(&#8220;&#8221;&#8221;<br \/>\nCREATE TABLE studentinfo<br \/>\n(<br \/>\nid INTEGER PRIMARY KEY AUTOINCREMENT,<br \/>\nname TEXT,<br \/>\nsubject TEXT<br \/>\n)<br \/>\n&#8220;&#8221;&#8221;)<\/p>\n<p>Let&#8217;s check how many tables we&#8217;ve added to the database by running a simple SQLite query.<\/p>\n<p>cursor.execute(&#8220;&#8221;&#8221;<br \/>\nSELECT name<br \/>\nFROM sqlite_master<br \/>\nWHERE type=&#8217;table&#8217;<br \/>\n&#8220;&#8221;&#8221;)<br \/>\ncursor.fetchall()<\/p>\n<p>&gt;&gt;&gt; [(&#8216;airport&#8217;,), (&#8216;studentinfo&#8217;,)]\n<h2><span class=\"ez-toc-section\" id=\"Running_a_query\"><\/span><strong>Running a query<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this section we will add values \u200b\u200bto the student information table and run simple SQL queries. Using INSERT INTO we can add a row to the student information table.<\/p>\n<p>To insert values, we need to provide the query and value arguments to the execute function. This function responds to \u201c? &#8221; items we provide.<\/p>\n<p>query = &#8220;&#8221;&#8221;<br \/>\nINSERT INTO studentinfo<br \/>\n(name, subject)<br \/>\nVALUES (?, ?)<br \/>\n&#8220;&#8221;&#8221;<br \/>\nvalue = (&#8220;Marry&#8221;, &#8220;Math&#8221;)<br \/>\ncursor.execute(query,value)<\/p>\n<p>Repeat the query on more records.<\/p>\n<p>query = &#8220;&#8221;&#8221;<br \/>\nINSERT INTO studentinfo<br \/>\n(name, subject)<br \/>\nVALUES (?, ?)<br \/>\n&#8220;&#8221;&#8221;<br \/>\nvalues = [(&#8220;Abid&#8221;, &#8220;Stat&#8221;),<br \/>\n(&#8220;Carry&#8221;, &#8220;Math&#8221;),<br \/>\n(&#8220;Ali&#8221;,&#8221;Data Science&#8221;),<br \/>\n(&#8220;Nisha&#8221;,&#8221;Data Science&#8221;),<br \/>\n(&#8220;Matthew&#8221;,&#8221;Math&#8221;),<br \/>\n(&#8220;Henry&#8221;,&#8221;Data Science&#8221;)]\n<p>cursor.executemany(query,values)<\/p>\n<p>It&#8217;s time to check the file. To do this, we will run a simple SQL query that will return rows whose subject is Data Science.<\/p>\n<p>cursor.execute(&#8220;&#8221;&#8221;<br \/>\nSELECT *<br \/>\nFROM studentinfo<br \/>\nWHERE subject LIKE &#8216;Data Science&#8217;<br \/>\n&#8220;&#8221;&#8221;)<br \/>\ncursor.fetchall()<\/p>\n<p>&gt;&gt;&gt; [(4, &#8216;Ali&#8217;, &#8216;Data Science&#8217;),<br \/>\n(5, &#8216;Nisha&#8217;, &#8216;Data Science&#8217;),<br \/>\n(7, &#8216;Henry&#8217;, &#8216;Data Science&#8217;)]\n<p>The DISTINCT subject command is used to display unique values \u200b\u200bcontained in subject columns. In our case, this is mathematics, statistics and data science.<\/p>\n<p>cursor.execute(&#8220;SELECT DISTINCT subject from studentinfo&#8221;)<br \/>\ncursor.fetchall()<\/p>\n<p>&gt;&gt; [(&#8216;Math&#8217;,), (&#8216;Stat&#8217;,), (&#8216;Data Science&#8217;,)]\n<p>To save all the changes, we will use the commit() function. If not authenticated, data will be lost after restarting the device.<\/p>\n<p>conn.commit()<\/p>\n<h2><span class=\"ez-toc-section\" id=\"SQL_with_Pandas\"><\/span><strong>SQL with Pandas<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this section, we will learn how to extract data from an SQLite database and convert it to a Pandas data frame using a single line of code. read_sql provides more than just executing SQL queries. We can use it to define index columns, parse date and time, add values, and filter column names. Learn more about importing data with Python by taking the short DataCamp course.<\/p>\n<p>read_sql requires two arguments: an SQL query and a connection to the SQLite engine. The output contains the first five rows of the airports table where PercentOfBaseline is greater than 20.<\/p>\n<p>data_sql_1 = pd.read_sql(&#8220;&#8221;&#8221;<br \/>\nSELECT Date,City,PercentOfBaseline<br \/>\nFROM airport<br \/>\nWHERE PercentOfBaseline &gt; 20<br \/>\nORDER BY Date DESC<br \/>\n&#8220;&#8221;&#8221;,<br \/>\nconn)<br \/>\nprint(data_sql_1.head())<\/p>\n<p>Date City PercentOfBaseline<br \/>\n0 2020-12-02 Sydney 27<br \/>\n1 2020-12-02 Santiago 48<br \/>\n2 2020-12-02 Calgary 99<br \/>\n3 2020-12-02 Leduc County 100<br \/>\n4 2020-12-02 Richmond 86<\/p>\n<p style=\"text-align: center\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Unlock Your Coding Potential with Our Python Programming Course \u2013 Enroll Today<\/a><\/strong><\/p>\n<p>Performing data analytics on relational databases has become easier with the Pandas integration. We can also use this data to predict values \u200b\u200band perform complex statistical analyses. The plot function allows you to visualize a histogram of the PercentOfBaseline column.<\/p>\n<p>data_sql_1.plot(y=&#8221;PercentOfBaseline&#8221;,kind=&#8221;hist&#8221;);<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.datacamp.com\/image\/upload\/v1649063788\/image6_n9513x.png\" \/><\/p>\n<p>Similarly, we can limit the values \u200b\u200bto the first 20 values \u200b\u200band display a time series line chart.<\/p>\n<p>data_sql_2 = pd.read_sql(&#8220;&#8221;&#8221;<br \/>\nSELECT Date,City,PercentOfBaseline<br \/>\nFROM airport<br \/>\nWHERE PercentOfBaseline &gt; 20<br \/>\nORDER BY Date DESC<br \/>\nLIMIT 20<br \/>\n&#8220;&#8221;&#8221;,<br \/>\nconn)<\/p>\n<p>data_sql_2.plot(x=&#8221;Date&#8221;,y=&#8221;PercentOfBaseline&#8221;,kind=&#8221;line&#8221;);<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.datacamp.com\/image\/upload\/v1649063788\/image3_r33zb2.png\" \/><\/p>\n<p>Finally we will close the connection to free up resources. Most packages do this automatically, but it&#8217;s best to close the connection after the changes are complete.<\/p>\n<p>conn.close()<\/p>\n<h2><span class=\"ez-toc-section\" id=\"R_Tutorial\"><\/span><strong>R Tutorial<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We will copy all the tasks from the Python tutorial using R. The tutorial covers creating connections, writing tables, adding rows, running queries, and analyzing data using dplyr.<\/p>\n<p><strong>Configuration<\/strong><\/p>\n<p>The DBI package is used to connect to the most popular databases such as MariaDB, Postgres, Duckdb and SQLite. For example, install the RMySQL package and create a database by providing a username, password, database name, and server address.<\/p>\n<p>install.packages(&#8220;RMySQL&#8221;)<br \/>\nlibrary(RMySQL)<br \/>\nconn = dbConnect(<br \/>\nMySQL(),<br \/>\nuser = &#8216;abid&#8217;,<br \/>\npassword = &#8216;1234&#8217;,<br \/>\ndbname = &#8216;datacamp_R&#8217;,<br \/>\nhost = &#8216;localhost&#8217;<br \/>\n)<\/p>\n<p>In this tutorial, we will create an SQLite database by providing an SQLite name and function.<\/p>\n<p>library(RSQLite)<br \/>\nlibrary(DBI)<br \/>\nlibrary(tidyverse)<\/p>\n<p>conn = dbConnect(SQLite(), dbname = &#8216;datacamp_R.db&#8217;)<\/p>\n<p style=\"text-align: center\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Unlock Your Coding Potential with Our Python Programming Course \u2013 Enroll Today<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Creating_Database\"><\/span><strong>Creating Database<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>By importing the Tidyverse library we will have access to the dplyr, ggplot and default datasets.<\/p>\n<p>The dbWriteTable function takes the data.frame and adds it to the SQL table. It takes three arguments: the connection to SQLite, the table name, and the data frame. With dbReadTable we can view the entire table. To display the first 6 lines we use head.<\/p>\n<p>dbWriteTable(conn, &#8220;cars&#8221;, mtcars)<br \/>\nhead(dbReadTable(conn, &#8220;cars&#8221;))<\/p>\n<p>mpg cyl disp hp drat wt qsec vs am gear carb<br \/>\n1 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4<br \/>\n2 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4<br \/>\n3 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1<br \/>\n4 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1<br \/>\n5 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2<br \/>\n6 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1<\/p>\n<p>dbExecute allows us to execute any SQLite query, so we will use it to create a table called idcard.<\/p>\n<p>To display table names in the database, we will use dbListTables.<\/p>\n<p>dbExecute(conn, &#8216;CREATE TABLE idcard (id int, name text)&#8217;)<br \/>\ndbListTables(conn)<\/p>\n<p>&gt;&gt;&gt; &#8216;cars&#8221;idcard&#8217;<\/p>\n<p>Let&#8217;s add a row to the idcard table and use dbGetQuery to display the results.<\/p>\n<p>Note: dbGetQuery executes the query and returns records while dbExecute executes the SQL query but returns no records.<\/p>\n<p>dbExecute(conn, &#8220;INSERT INTO idcard (id,name)\\<br \/>\nVALUES(1,&#8217;love&#8217;)&#8221;)<br \/>\ndbGetQuery(conn,&#8221;SELECT * FROM idcard&#8221;)<\/p>\n<p>id name<br \/>\n1 love<\/p>\n<p>Now we will add two more rows and display the results using dbReadTable.<\/p>\n<p>dbExecute(conn,&#8221;INSERT INTO idcard (id,name)\\<br \/>\nVALUES(2,&#8217;Kill&#8217;),(3,&#8217;Game&#8217;)<br \/>\n&#8220;)<br \/>\ndbReadTable(conn,&#8217;idcard&#8217;)<\/p>\n<p>id name<br \/>\n1 love<br \/>\n2 Kill<br \/>\n3 Game<\/p>\n<p>dbCreateTable allows us to create tables easily. This requires three arguments; connection, table name, and character vector or data.frame. Character vector includes name (column name) and value (type). In our case, we will provide a default population data.frame to create the initial structure.<\/p>\n<p>dbCreateTable(conn,&#8217;population&#8217;,population)<br \/>\ndbReadTable(conn,&#8217;population&#8217;)<\/p>\n<p>country year population<\/p>\n<p>Next, we will use dbAppendTable to add values \u200b\u200bto the population table.<\/p>\n<p>dbAppendTable(conn,&#8217;population&#8217;,head(population))<br \/>\ndbReadTable(conn,&#8217;population&#8217;)<\/p>\n<p>country year population<br \/>\nAfghanistan 1995 17586073<br \/>\nAfghanistan 1996 18415307<br \/>\nAfghanistan 1997 19021226<br \/>\nAfghanistan 1998 19496836<br \/>\nAfghanistan 1999 19987071<br \/>\nAfghanistan 2000 20595360<\/p>\n<h2 id=\"running-queries-wewil\"><span class=\"ez-toc-section\" id=\"Running_Queries\"><\/span><strong>Running Queries<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p class=\"p-margin\">We will use\u00a0<code>dbGetQuery<\/code> to perform all of our data analytics tasks. Let\u2019s try to run a simple query and then learn more about other functions.<\/p>\n<p>dbGetQuery(conn,&#8221;SELECT * FROM idcard&#8221;)<\/p>\n<p>id name<br \/>\n1 love<br \/>\n2 Kill<br \/>\n3 Game<\/p>\n<p class=\"p-margin\">You can also run a complex SQL query to filter and display limited rows and columns.<\/p>\n<p>dbGetQuery(conn, &#8220;SELECT mpg,hp,gear\\<br \/>\nFROM cars\\<br \/>\nWHERE hp &gt; 50\\<br \/>\nLIMIT 5&#8221;)<\/p>\n<p>mpg hp gear<br \/>\n21.0 110 4<br \/>\n21.0 110 4<br \/>\n22.8 93 4<br \/>\n21.4 110 3<br \/>\n18.7 175 3<\/p>\n<div class=\"parent\">\n<div class=\"parent\">\n<p class=\"p-margin\">To remove a table, use dbRemoveTable. As we can see now we have successfully removed the ID card table.<\/p>\n<p>dbRemoveTable(conn,&#8217;idcard&#8217;)<br \/>\ndbListTables(conn)<br \/>\n&gt;&gt;&gt; &#8216;cars&#8221;population&#8217;<\/p>\n<div class=\"parent\">\n<p class=\"p-margin\">To understand tables better, we will use dbListFields to display column names in a particular table.<\/p>\n<p>dbListFields(conn, &#8220;cars&#8221;)<\/p>\n<p>&gt;&gt;&gt; &#8216;mpg&#8221;cyl&#8221;disp&#8221;hp&#8221;drat&#8221;wt&#8221;qsec&#8221;vs&#8221;am&#8221;gear&#8221;carb&#8217;<\/p>\n<div class=\"parent\">\n<h3 id=\"sql-with-dplyr-inthi\"><strong>SQL with dplyr<\/strong><\/h3>\n<p class=\"p-margin\">In this section, we will use dplyr to read the table and then run queries using filter, select, and collect. If you don&#8217;t want to learn SQL syntax and want to do all the tasks in pure R, then this method is for you. We extract the cars table, filter by speed and mpg, then select three columns as shown below.<\/p>\n<p>cars_results &lt;-<br \/>\ntbl(conn, &#8220;cars&#8221;) %&gt;%<br \/>\nfilter(gear %in% c(4, 3),<br \/>\nmpg &gt;= 14,<br \/>\nmpg &lt;= 21) %&gt;%<br \/>\nselect(mpg, hp, gear) %&gt;%<br \/>\ncollect()<br \/>\ncars_results<\/p>\n<p>mpg hp gear<br \/>\n21.0 110 4<br \/>\n21.0 110 4<br \/>\n18.7 175 3<br \/>\n18.1 105 3<br \/>\n14.3 245 3<\/p>\n<p class=\"p-margin\">We can use a filtered data frame to display a box and whisker plot using ggplot.<\/p>\n<p>ggplot(cars_results,aes(fill=as.character(gear), y=mpg)) +<br \/>\ngeom_boxplot()<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.datacamp.com\/image\/upload\/v1649063788\/image4_muzlef.png\" \/><\/p>\n<p class=\"p-margin\">Or we can display a facet point plot divided by the number of gears.<\/p>\n<p>ggplot(cars_results,<br \/>\naes(mpg, ..count.. ) ) +<br \/>\ngeom_point(stat = &#8220;count&#8221;, size = 4) +<br \/>\ncoord_flip()+<br \/>\nfacet_grid( as.character(gear) ~ . )<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.datacamp.com\/image\/upload\/v1649063788\/image1_gnoejp.png\" \/><\/p>\n<p style=\"text-align: center\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Unlock Your Coding Potential with Our Python Programming Course \u2013 Enroll Today<\/a><\/strong><\/p>\n<p><strong style=\"color: #212121;font-size: 1.953em\">Conclusion<\/strong><\/p>\n<\/div>\n<div class=\"parent\">\n<div class=\"parent\">\n<p class=\"p-margin\">In this tutorial, we learned the importance of running SQL queries with Python and R, creating databases, adding tables, and performing data analysis using SQL queries. We also learned how Pandas and dplyr help us run queries with just one line of code.<\/p>\n<p class=\"p-margin\">SQL is an essential skill for any technology-related job. If you are starting your career as a Data Analyst, we recommend completing the Data Analyst with SQL Server career path within two months. This career path will teach you all about SQL queries, servers, and resource management.<\/p>\n<p class=\"p-margin\">\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"parent\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The world&#8217;s most popular code language for data analysis just got a little simpler. We have demonstrated simple and effective ways to run SQL queries in Python and R, especially for data analysis and database management. What is SQL? Structured Query Language (SQL) is the most commonly used language to perform various data analysis tasks. [&hellip;]<\/p>\n","protected":false},"author":110,"featured_media":25576621,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1888],"tags":[],"class_list":["post-25576579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-python-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"The world&#8217;s most popular code language for data analysis just got a little simpler. We have demonstrated simple and effective ways to run SQL queries in Python and R, especially for data analysis and database management. What is SQL? Structured Query Language (SQL) is the most commonly used language to perform various data analysis tasks. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-25T21:18:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Juwairiya Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Juwairiya Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\"},\"author\":{\"name\":\"Juwairiya Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc\"},\"headline\":\"How to Execute SQL Queries in Python and R Tutorial (Experts Guide)\",\"datePublished\":\"2024-02-25T21:18:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\"},\"wordCount\":2497,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png\",\"articleSection\":[\"Articles\",\"Python Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\",\"url\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\",\"name\":\"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png\",\"datePublished\":\"2024-02-25T21:18:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png\",\"width\":820,\"height\":615,\"caption\":\"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) (1)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/python-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Execute SQL Queries in Python and R Tutorial (Experts Guide)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc\",\"name\":\"Juwairiya Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/juwairiyaentri\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog","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:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/","og_locale":"en_US","og_type":"article","og_title":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog","og_description":"The world&#8217;s most popular code language for data analysis just got a little simpler. We have demonstrated simple and effective ways to run SQL queries in Python and R, especially for data analysis and database management. What is SQL? Structured Query Language (SQL) is the most commonly used language to perform various data analysis tasks. [&hellip;]","og_url":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2024-02-25T21:18:12+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png","type":"image\/png"}],"author":"Juwairiya Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Juwairiya Mahin","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/"},"author":{"name":"Juwairiya Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc"},"headline":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide)","datePublished":"2024-02-25T21:18:12+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/"},"wordCount":2497,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png","articleSection":["Articles","Python Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/","url":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/","name":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png","datePublished":"2024-02-25T21:18:12+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/02\/How-to-Execute-SQL-Queries-in-Python-and-R-Tutorial-Experts-Guide-1.png","width":820,"height":615,"caption":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide) (1)"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/how-to-execute-sql-queries-in-python-and-r-tutorial-experts-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Programming","item":"https:\/\/entri.app\/blog\/category\/python-programming\/"},{"@type":"ListItem","position":3,"name":"How to Execute SQL Queries in Python and R Tutorial (Experts Guide)"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc","name":"Juwairiya Mahin","url":"https:\/\/entri.app\/blog\/author\/juwairiyaentri\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25576579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25576579"}],"version-history":[{"count":1,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25576579\/revisions"}],"predecessor-version":[{"id":25576622,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25576579\/revisions\/25576622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25576621"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25576579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25576579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25576579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}