{"id":4157,"date":"2024-07-24T13:07:24","date_gmt":"2024-07-24T06:07:24","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=4157"},"modified":"2024-07-24T19:50:52","modified_gmt":"2024-07-24T12:50:52","slug":"python-sql-server-call-stored-procedures","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/","title":{"rendered":"Python SQL Server: Call Stored Procedures"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to call a SQL server&#8217;s stored procedure from a Python program.<\/p>\n\n\n\n<p class=\"note\">This tutorial begins where\u00a0the\u00a0<a href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-transaction\/\">performing database transactions in Python program tutorial<\/a> left off.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='creating-a-stored-procedure'>Creating a stored procedure <a href=\"#creating-a-stored-procedure\" class=\"anchor\" id=\"creating-a-stored-procedure\" title=\"Anchor for Creating a stored procedure\">#<\/a><\/h2>\n\n\n\n<p>Step 1. Launch Microsoft SQL Server Management Studio (SSMS) and connect to the SQL Server.<\/p>\n\n\n\n<p>Step 2. <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-stored-procedures\/\">Create a new stored procedure<\/a> by executing the following statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">PROCEDURE<\/span> GetBooksByPublishedDate\n    @StartDate <span class=\"hljs-built_in\">DATE<\/span>,\n    @EndDate <span class=\"hljs-built_in\">DATE<\/span>\n<span class=\"hljs-keyword\">AS<\/span>\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- Check for valid date range<\/span>\n    <span class=\"hljs-keyword\">IF<\/span> @StartDate &gt; @EndDate\n    <span class=\"hljs-keyword\">BEGIN<\/span>\n        PRINT <span class=\"hljs-string\">'Error: Start date must be less than or equal to end date.'<\/span>\n        <span class=\"hljs-keyword\">RETURN<\/span>\n    <span class=\"hljs-keyword\">END<\/span>\n\n    <span class=\"hljs-comment\">-- Retrieve books within the date range<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> BookID, Title, Publisher, ISBN, PublishedDate\n    <span class=\"hljs-keyword\">FROM<\/span> Books\n    <span class=\"hljs-keyword\">WHERE<\/span> PublishedDate <span class=\"hljs-keyword\">BETWEEN<\/span> @StartDate <span class=\"hljs-keyword\">AND<\/span> @EndDate\n    <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> PublishedDate;\n<span class=\"hljs-keyword\">END<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>GetBooksByPublishedDate<\/code> stored procedure returns a list of books between start and end dates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='calling-the-stored-procedures'>Calling the stored procedures <a href=\"#calling-the-stored-procedures\" class=\"anchor\" id=\"calling-the-stored-procedures\" title=\"Anchor for Calling the stored procedures\">#<\/a><\/h2>\n\n\n\n<p>Step 1. Create a new module <code>procedure.py<\/code> with the following code:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> create_connection\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">get_books_by_published_date<\/span><span class=\"hljs-params\">(start_date: str, end_date: str)<\/span> -&gt; list&#91;dict] | <span class=\"hljs-keyword\">None<\/span>:<\/span>\n    <span class=\"hljs-comment\"># Connect to the SQL Server<\/span>\n    conn = create_connection()\n    <span class=\"hljs-keyword\">if<\/span> conn <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">None<\/span>\n    \n    <span class=\"hljs-comment\"># Call the stored procedure<\/span>\n    <span class=\"hljs-keyword\">with<\/span> (conn, conn.cursor(as_dict=<span class=\"hljs-literal\">True<\/span>) <span class=\"hljs-keyword\">as<\/span> cursor):\n        cursor.callproc(<span class=\"hljs-string\">'GetBooksByPublishedDate'<\/span>, (start_date, end_date))\n        <span class=\"hljs-keyword\">return<\/span> cursor.fetchall()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, import the <code>create_connection<\/code> function from the <a href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-connect-to-sql-server\/\">connect<\/a> module:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> create_connection<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, define <code>get_books_by_published_date()<\/code> function that returns a list of books with the published date within <code>start_date<\/code> and <code>end_date<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">get_books_by_published_date<\/span><span class=\"hljs-params\">(start_date: str, end_date: str)<\/span> -&gt; list&#91;dict] | <span class=\"hljs-keyword\">None<\/span>:<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, connect to SQL Server by calling the <code>create_connection()<\/code> function and return <code>None<\/code> if the connection fails:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">conn = create_connection()\n<span class=\"hljs-keyword\">if<\/span> conn <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">None<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, manage the <code>Connection<\/code> and <code>Cursor<\/code> objects using the <code>with<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">with<\/span> (conn, conn.cursor() <span class=\"hljs-keyword\">as<\/span> cursor):<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Sixth, call the stored procedure by calling the <code>callproc()<\/code> method of the <code>Cursor<\/code> object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cursor.callproc(<span class=\"hljs-string\">'GetBooksByPublishedDate'<\/span>, (start_date, end_date))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Notice that you need to pass a tuple that includes the stored procedure&#8217;s parameters to the second argument of the <code>callproc()<\/code> method.<\/p>\n\n\n\n<p>Finally, return all the rows from the query result:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">return<\/span> cursor.fetchall()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 2. Modify the <code>main.py<\/code> module to use the <code>get_books_by_published_date()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> logging, sys\n<span class=\"hljs-keyword\">from<\/span> procedure <span class=\"hljs-keyword\">import<\/span> get_books_by_published_date\n\n\n<span class=\"hljs-comment\"># config logging to console<\/span>\nlogging.basicConfig(\n    stream=sys.stdout, \n    encoding=<span class=\"hljs-string\">'utf-8'<\/span>, \n    format=<span class=\"hljs-string\">'%(levelname)s:%(message)s'<\/span>,\n    level=logging.DEBUG\n)\n\n\nbooks = get_books_by_published_date(<span class=\"hljs-string\">'2022-01-01'<\/span>, <span class=\"hljs-string\">'2023-12-31'<\/span>)\n<span class=\"hljs-keyword\">for<\/span> book <span class=\"hljs-keyword\">in<\/span> books:\n    print(<span class=\"hljs-string\">f'<span class=\"hljs-subst\">{book&#91;<span class=\"hljs-string\">\"Title\"<\/span>]}<\/span> - Published on <span class=\"hljs-subst\">{book&#91;<span class=\"hljs-string\">\"PublishedDate\"<\/span>]}<\/span>'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, import the <code>get_books_by_published_date<\/code> function from the procedure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> procedure <span class=\"hljs-keyword\">import<\/span> get_books_by_published_date<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, call the <code>get_books_by_published_date<\/code> function to get the books published between <code>Jan 01, 2022<\/code> and <code>Dec 31, 2023<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">books = get_books_by_published_date(<span class=\"hljs-string\">'2022-01-01'<\/span>, <span class=\"hljs-string\">'2023-12-31'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, display the book title and published date of returning books:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">for<\/span> book <span class=\"hljs-keyword\">in<\/span> books:\n    print(<span class=\"hljs-string\">f'<span class=\"hljs-subst\">{book&#91;<span class=\"hljs-string\">\"Title\"<\/span>]}<\/span> - Published on <span class=\"hljs-subst\">{book&#91;<span class=\"hljs-string\">\"PublishedDate\"<\/span>]}<\/span>'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 3. Open your terminal and run the <code>main.py<\/code> module:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">python main.py<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Mastering SQL: A Comprehensive Guide - Published on <span class=\"hljs-number\">2022<\/span><span class=\"hljs-number\">-01<\/span><span class=\"hljs-number\">-15<\/span>\nDatabase Systems: Theory <span class=\"hljs-keyword\">and<\/span> Practice - Published on <span class=\"hljs-number\">2022<\/span><span class=\"hljs-number\">-11<\/span><span class=\"hljs-number\">-05<\/span>\nSQL Queries <span class=\"hljs-keyword\">for<\/span> Mere Mortals - Published on <span class=\"hljs-number\">2023<\/span><span class=\"hljs-number\">-03<\/span><span class=\"hljs-number\">-21<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='download-the-project-source-code'>Download the project source code <a href=\"#download-the-project-source-code\" class=\"anchor\" id=\"download-the-project-source-code\" title=\"Anchor for Download the project source code\">#<\/a><\/h2>\n\n\n\n<p>Download the project source code<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Call the <code>execute()<\/code> method of a <code>Cursor<\/code> object to call a SQL Server&#8217;s stored procedure.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"4157\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/\"\n\t\t\t\tdata-post-title=\"Python SQL Server: Call Stored Procedures\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"4157\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/\"\n\t\t\t\tdata-post-title=\"Python SQL Server: Call Stored Procedures\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to call a SQL server&#8217;s stored procedure from a Python program.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":4049,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4157","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python SQL Server: Call Stored Procedures<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to call a SQL server&#039;s stored procedure from a Python program.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python SQL Server: Call Stored Procedures\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to call a SQL server&#039;s stored procedure from a Python program.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-24T12:50:52+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-call-stored-procedures\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-call-stored-procedures\\\/\",\"name\":\"Python SQL Server: Call Stored Procedures\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"datePublished\":\"2024-07-24T06:07:24+00:00\",\"dateModified\":\"2024-07-24T12:50:52+00:00\",\"description\":\"In this tutorial, you will learn how to call a SQL server's stored procedure from a Python program.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-call-stored-procedures\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-call-stored-procedures\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/python-sql-server-call-stored-procedures\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python SQL Server\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/python-sql-server\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python SQL Server: Call Stored Procedures\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python SQL Server: Call Stored Procedures","description":"In this tutorial, you will learn how to call a SQL server's stored procedure from a Python program.","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:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/","og_locale":"en_US","og_type":"article","og_title":"Python SQL Server: Call Stored Procedures","og_description":"In this tutorial, you will learn how to call a SQL server's stored procedure from a Python program.","og_url":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-07-24T12:50:52+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/","url":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/","name":"Python SQL Server: Call Stored Procedures","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"datePublished":"2024-07-24T06:07:24+00:00","dateModified":"2024-07-24T12:50:52+00:00","description":"In this tutorial, you will learn how to call a SQL server's stored procedure from a Python program.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/python-sql-server-call-stored-procedures\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"Python SQL Server","item":"https:\/\/www.sqlservertutorial.net\/python-sql-server\/"},{"@type":"ListItem","position":3,"name":"Python SQL Server: Call Stored Procedures"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=4157"}],"version-history":[{"count":5,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4157\/revisions"}],"predecessor-version":[{"id":4199,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4157\/revisions\/4199"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4049"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=4157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}