Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to execute MySQL Stored Procedure in Python

import mysql.connector
from mysql.connector import Error

try:
    connection = mysql.connector.connect(host='localhost',
                                         database='Electronics',
                                         user='pynative',
                                         password='pynative@#29')
    cursor = connection.cursor()
    cursor.callproc('get_laptop', [1, ])
    # print results
    print("Printing laptop details")
    for result in cursor.stored_results():
        print(result.fetchall())

except mysql.connector.Error as error:
    print("Failed to execute stored procedure: {}".format(error))
finally:
    if (connection.is_connected()):
        cursor.close()
        connection.close()
        print("MySQL connection is closed")
Comment

PREVIOUS NEXT
Code Example
Sql :: alter boolean column postgresql 
Sql :: download sql server 2014 
Sql :: display first three characters sql 
Sql :: sql insert exemplo 
Sql :: nested select sql 
Sql :: json to dynamic columns in sql 
Sql :: declare date variable sql 
Sql :: how to move a column to different spot mysql 
Sql :: postgres select except 
Sql :: sql exemplos 
Sql :: how to check default value of column in sql server 
Sql :: sqlalchemy case insensitive like 
Sql :: pl sql create function 
Sql :: first max salary in sql 
Sql :: SQL get max per id 
Sql :: sql float 3 decimal places 
Sql :: sum row in sql 
Sql :: select year from dual oracle 
Sql :: mysql autoincrement valor inicial 
Sql :: psql attribute cannot login 
Sql :: sql cte example 
Sql :: SQL Copy From Two Tables to One 
Sql :: sqlcmd list tables 
Sql :: postgres insert timestamp without timezone 
Sql :: sqlalchemy existing db file 
Sql :: Create parameterized VIEW in SQL Server 
Sql :: create procedure 
Sql :: Triggers Syntax 
Sql :: sql like with multiple values 
Sql :: mysql multiply 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =