{"id":100929,"date":"2021-03-22T11:00:00","date_gmt":"2021-03-22T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=100929"},"modified":"2021-03-11T15:00:05","modified_gmt":"2021-03-11T13:00:05","slug":"python-execute-mysql-stored-procedure","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/","title":{"rendered":"Python Execute MySQL Stored Procedure"},"content":{"rendered":"<p>Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming.<\/p>\n<h2>1. Introduction<\/h2>\n<p>To connect with MySQL in python programming we have the following modules that are commonly available and known to the developer world as all these modules adhere to the <a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0249\/\" target=\"_blank\" rel=\"noopener\">python database api specification<\/a> &#8211;<\/p>\n<ul>\n<li>MySQL Connector Python \u2013 It is a preferred choice in the developer\u2019s community as it is capable of executing database queries through python. It is python3 compatible and actively maintained<\/li>\n<li>pyMySQL<\/li>\n<li>MySQLDB<\/li>\n<li>MySqlClient<\/li>\n<\/ul>\n<h3>1.1 Setting up Python<\/h3>\n<p>If someone needs to go through the Python installation on Windows, please watch <a href=\"https:\/\/www.youtube.com\/watch?v=i-MuSAwgwCU\" target=\"_blank\" rel=\"noopener\">this<\/a> link. You can download the Python from <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">this<\/a> link.<\/p>\n<h3>1.2 Setting up MySQL Connector Python<\/h3>\n<p>Once the python is successfully installed on your system you can install the <strong>MySQL Connector Python<\/strong> using a simple <code>pip<\/code> command. You can fire the below command from the command prompt and it will successfully download the module from <a href=\"https:\/\/pypi.org\/project\/mysql-connector-python\/\" target=\"_blank\" rel=\"noopener\">pypi.org<\/a> and install it.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Installation command<\/em><\/span><\/p>\n<pre class=\"brush:python;\">pip install mysql-connector-python\n<\/pre>\n<h3>1.3 Setting up MySQL database and PhpMyAdmin containers<\/h3>\n<p>To start with the tutorial, I am hoping that you have the MySQL up and running in your localhost environment. For easy setup, I have the database up and running on the docker environment. Along with the database, we will also bring up the PhpMyAdmin container to connect with the database. You can execute the below command to get the containers running on docker in minutes.<\/p>\n<p>You can execute the below command to get the container running on docker in minutes.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Docker commands<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">docker run --name mysql -e MYSQL_ROOT_PASSWORD=password123 -e MYSQL_DATABASE=user -p 3306:3306 -d mysql\n\ndocker run --name phpmyadmin --link mysql:db -p 8089:80 -d phpmyadmin\/phpMyAdmin\n<\/pre>\n<p>If everything goes well the containers would be started successfully as shown in Fig. 1. You can use the <code>docker ps -a<\/code> command to confirm that both containers are started successfully. For further information on docker basics, you can navigate to this <a href=\"https:\/\/examples.javacodegeeks.com\/docker-basic-commands\/\" target=\"_blank\" rel=\"noopener\">tutorial<\/a>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/mysqlconnectorpython-mysql-module.jpeg\"><img decoding=\"async\" width=\"799\" height=\"299\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/mysqlconnectorpython-mysql-module.jpeg\" alt=\"python mysql stored procedure - phpmyadmin containers\" class=\"wp-image-100930\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/mysqlconnectorpython-mysql-module.jpeg 799w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/mysqlconnectorpython-mysql-module-300x112.jpeg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/mysqlconnectorpython-mysql-module-768x287.jpeg 768w\" sizes=\"(max-width: 799px) 100vw, 799px\" \/><\/a><figcaption>Fig. 1: MySQL database and PhpMyAdmin containers on Docker<\/figcaption><\/figure>\n<\/div>\n<p>Once the PhpMyAdmin container is started successfully you can navigate to the following url &#8211; <code>http:\/\/localhost:8089\/<\/code> in the browser. Enter the login credentials as <code>root<\/code> and <code>password123<\/code> to enter into the console. You are free to keep the mysql login credentials of your choice by changing them in the docker command for the mysql container.<\/p>\n<h2>2. Python Execute MySQL Stored Procedure<\/h2>\n<p>Before going any deeper in the practical let me walk you through a simple architecture diagram where it shows that wherein the mysql connector python module fits in the picture.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/docker-mysql-phpmyadmin-containers-img1.jpg\"><img decoding=\"async\" width=\"818\" height=\"588\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/docker-mysql-phpmyadmin-containers-img1.jpg\" alt=\"python mysql stored procedure - connection\" class=\"wp-image-100931\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/docker-mysql-phpmyadmin-containers-img1.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/docker-mysql-phpmyadmin-containers-img1-300x216.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/docker-mysql-phpmyadmin-containers-img1-768x552.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption>Fig. 2: Python MySQL connection<\/figcaption><\/figure>\n<\/div>\n<p>For the MySQL connector python module to work we will supply the following attributes to the mysql from the python application i.e.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li><strong>user<\/strong> \u2013 Identity user to work with the mysql database. Default mysql user is <code>root<\/code><\/li>\n<li><strong>password<\/strong> \u2013 Credential of the identity user<\/li>\n<li><strong>host<\/strong> \u2013 Address of the database server. If running on localhost then you can either use localhost or 127.0.0.1<\/li>\n<li><strong>port<\/strong> &#8211; The port number. Default mysql port is <code>3306<\/code><\/li>\n<li><strong>database<\/strong> \u2013 Database to which you want to connect. It can be left blank<\/li>\n<\/ul>\n<h3>2.1 Prerequisite &#8211; Create SQL data<\/h3>\n<p>For this tutorial, we will need to create a table and populate some dummy data into it so that we can use this table for SQL operations. You can use the following SQL script. Make note that the <code>user<\/code> database was already created with the help of the docker run command for the mysql container.<\/p>\n<p><span style=\"text-decoration: underline\"><em>User.sql<\/em><\/span><\/p>\n<pre class=\"brush:sql;\">-- create database\nCREATE DATABASE user;\n\n-- use database\nUSE user;\n\n-- create table\nCREATE TABLE users (\n    id INT NOT NULL AUTO_INCREMENT,\n    first_name VARCHAR(50),\n    last_name VARCHAR(50),\n    email VARCHAR(50),\n    gender VARCHAR(50),\n    PRIMARY KEY(id));\n\n-- insert dummy data into a table\nINSERT INTO users (first_name, last_name, email, gender) VALUES ('Engracia', 'Gwyther', 'egwyther0@redcross.org', 'F');\nINSERT INTO users (first_name, last_name, email, gender) VALUES ('Ximenez', 'MacNeachtain', 'xmacneachtain1@posterous.com', 'NS');\nINSERT INTO users (first_name, last_name, email, gender) VALUES ('Fitzgerald', 'Hartus', 'fhartus2@cdbaby.com', 'M');\nINSERT INTO users (first_name, last_name, email, gender) VALUES ('Beniamino', 'Beirne', 'bbeirne3@engadget.com', 'F');\nINSERT INTO users (first_name, last_name, email, gender) VALUES ('Adriana', 'Armal', 'aarmal4@booking.com', 'NS');\n\n-- get all records from the table\nSELECT * FROM users;\n\n-- sql procedures\n-- CALL get_users()\nDELIMITER &amp;&amp;\nCREATE PROCEDURE get_users ()\nBEGIN\nSELECT * FROM users;\nEND &amp;&amp;\nDELIMITER ;\n\n-- CALL get_user_by_id(11)\nDELIMITER &amp;&amp;\nCREATE PROCEDURE get_user_by_id (IN U_id INT)\nBEGIN\nSELECT first_name, last_name, email, gender FROM users WHERE id = U_id;\nEND &amp;&amp;\nDELIMITER ;\n\n-- CALL insert_user('Jane','Doe','jane.doe@automation.com', 'M')\nDELIMITER &amp;&amp;\nCreate PROCEDURE insert_user (IN U_first_name VARCHAR(50), IN U_last_name VARCHAR(50), IN U_email Varchar(50), IN U_gender Varchar(50))\nBEGIN\nINSERT INTO users (first_name, last_name, email, gender) VALUES (U_first_name, U_last_name, U_email, U_gender);\nEND &amp;&amp;\nDELIMITER ;\n<\/pre>\n<h2>3. Code Example<\/h2>\n<p>Let us dive in with the programming stuff now.<\/p>\n<h3>3.1 Create a configuration file<\/h3>\n<p>Add the following code to the environment file wherein we will specify the connection and database details. You are free to change these details as per your configuration setup.<\/p>\n<p><span style=\"text-decoration: underline\"><em>local.env<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">[DB]\nusername = root\npassword = password123\nhost = localhost\nport = 3306\ndatabase = user\n<\/pre>\n<h3>3.2 Reading the configuration<\/h3>\n<p>Add the following code to the python script which will read the configuration file created above and return the config object to be used later while connecting to the database. The script will import the <code>configparser<\/code> module for reading the configuration file. Remember to give the correct path where the <code>local.env<\/code> is created.<\/p>\n<p><span style=\"text-decoration: underline\"><em>readdbconfig.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\">import configparser\ndef read_db_params():\n    # reading the env file\n    config = configparser.ConfigParser()\n    config.read('config\/local.env')\n    return config\n<\/pre>\n<h3>3.3 Connecting to the database<\/h3>\n<p>Add the following code to the python script which will connect to the mysql database with the help of the <code>mysql.connector<\/code> module.<\/p>\n<p><span style=\"text-decoration: underline\"><em>connecttomysqldb.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># python mysql\n\nimport mysql.connector\nfrom mysql.connector import Error\n\nfrom readdbconfig import *\n\n\ndef connect():\n    try:\n        # method will read the env file and return the config object\n        params = read_db_params()\n\n        # connect to database\n        # reading the database parameters from the config object\n        conn = mysql.connector.connect(\n            host=params.get('DB', 'host'),\n            database=params.get('DB', 'database'),\n            user=params.get('DB', 'username'),\n            password=params.get('DB', 'password'),\n            port=params.get('DB', 'port')\n        )\n\n        return conn\n    except(Exception, Error) as error:\n        print(error)\n<\/pre>\n<h3>3.4 Executing the stored procedures<\/h3>\n<p>Add the following code to the python script which will connect to the mysql database with the help of the <code>mysql.connector<\/code> module and call the stored procedures.<\/p>\n<p><span style=\"text-decoration: underline\"><em>callmysqlstoredprocedure.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># python mysql\n\nfrom connecttomysqldb import *\n\n\n# executing the stored procedure to get all users\ndef get_users(conn):\n    # creating a cursor to perform a sql operation\n    cursor = conn.cursor()\n\n    try:\n        # execute the command\n        cursor.callproc('get_users')\n\n        # print results\n        for result in cursor.stored_results():\n            records = result.fetchall()\n            if len(records) == 0:\n                print('Empty table')\n            else:\n                # print results\n                print('Printing user details')\n                print('----------------------------')\n                for record in records:\n                    full_name = record[1] + \" \" + record[2]\n                    print('Id = {}, Name = {}, Email = {}, Gender = {}'.format(record[0], full_name,\n                                                                               record[3], record[4]))\n    except(Exception, Error) as error:\n        print(error)\n    finally:\n        if conn is not None:\n            cursor.close()\n            conn.close()\n            print('\\nConnection closed')\n\n\n# executing the stored procedure to get user by id\ndef get_user_by_id(conn, uid):\n    # creating a cursor to perform a sql operation\n    cursor = conn.cursor()\n\n    try:\n        args = [uid]\n        # execute the command\n        cursor.callproc('get_user_by_id', args)\n\n        # print results\n        for result in cursor.stored_results():\n            records = result.fetchall()\n            if len(records) == 0:\n                print('Empty table')\n            else:\n                # print results\n                print('Printing user id = {} details'.format(uid))\n                print('------------------------------------')\n                for record in records:\n                    full_name = record[0] + \" \" + record[1]\n                    print('Name = {}, Email = {}, Gender = {}'.format(full_name, record[2], record[3]))\n    except(Exception, Error) as error:\n        print(error)\n    finally:\n        if conn is not None:\n            cursor.close()\n            conn.close()\n            print('\\nConnection closed')\n\n\n# driver code\nif __name__ == '__main__':\n    get_users(connect())\n    # get_user_by_id(connect(), 4)\n<\/pre>\n<h2>4. Demo logs<\/h2>\n<p>The <code>callmysqlstoredprocedure.py<\/code> script will call the <code>get_users()<\/code> stored procedure to fetch the users from the table and show it on the IDE console. If not the exception message will be shown.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Demo logs<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">-- CALL get_users()\n\nPrinting user details\n----------------------------\nId = 1, Name = Engracia Gwyther, Email = egwyther0@redcross.org, Gender = F\nId = 2, Name = Ximenez MacNeachtain, Email = xmacneachtain1@posterous.com, Gender = NS\nId = 3, Name = Fitzgerald Hartus, Email = fhartus2@cdbaby.com, Gender = M\nId = 4, Name = Beniamino Beirne, Email = bbeirne3@engadget.com, Gender = F\nId = 5, Name = Adriana Armal, Email = aarmal4@booking.com, Gender = NS\n<\/pre>\n<p>You can also call the <code>get_user_by_id(\u2026)<\/code> stored procedure to fetch the details of a particular user. That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>5. Summary<\/h2>\n<p>In this tutorial, we learned \u2013<\/p>\n<ul>\n<li>Introduction to mysql connector python module<\/li>\n<li>Sample program to connect to the database with the help of mysql connector python module and execute the stored procedures<\/li>\n<\/ul>\n<p>You can download the source code of this tutorial from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>6. Download the Project<\/h2>\n<p>This was a python programming tutorial to connect to the database with the help of the mysql connector python module.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/03\/Python-Execute-MySQL-Stored-Procedure.zip\" target=\"_blank\" rel=\"noopener\"><strong>Python Execute MySQL Stored Procedure<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To connect with MySQL in python programming we have the following modules that are commonly available and known to the developer world as all these modules adhere to the python database &hellip;<\/p>\n","protected":false},"author":119,"featured_media":99891,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46689],"tags":[647,1716],"class_list":["post-100929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-mysql","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Execute MySQL Stored Procedure - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Execute MySQL Stored Procedure - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-22T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Python Execute MySQL Stored Procedure\",\"datePublished\":\"2021-03-22T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\"},\"wordCount\":862,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"keywords\":[\"mysql\",\"python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\",\"name\":\"Python Execute MySQL Stored Procedure - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"datePublished\":\"2021-03-22T09:00:00+00:00\",\"description\":\"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"set python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/web-development\/python\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Python Execute MySQL Stored Procedure\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Execute MySQL Stored Procedure - Java Code Geeks","description":"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To","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:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/","og_locale":"en_US","og_type":"article","og_title":"Python Execute MySQL Stored Procedure - Java Code Geeks","og_description":"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To","og_url":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2021-03-22T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Python Execute MySQL Stored Procedure","datePublished":"2021-03-22T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/"},"wordCount":862,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","keywords":["mysql","python"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/","url":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/","name":"Python Execute MySQL Stored Procedure - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","datePublished":"2021-03-22T09:00:00+00:00","description":"Hello in this tutorial, we will understand how to connect to the MySQL database and call the stored procedures via python programming. 1. Introduction To","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","width":150,"height":150,"caption":"set python"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/python-execute-mysql-stored-procedure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/examples.javacodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"Python","item":"https:\/\/examples.javacodegeeks.com\/category\/web-development\/python\/"},{"@type":"ListItem","position":4,"name":"Python Execute MySQL Stored Procedure"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/100929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=100929"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/100929\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/99891"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=100929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=100929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=100929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}