Python MySQL Tutorials | Handling Stored Procedures in Python | Python Procedures | MySQL in Python

Publié le: 27 novembre 2020
sur la chaîne: CodeAsItIs
4,130
53

Python MySQL Tutorials | Handling Stored Procedures in Python | Python Procedures | MySQL in Python
#Python #CodeAsItIs #PythonMySQL
To call a stored procedure in Python, you must follow below :
Step 1 - Connect to MySQL database by creating a new MySQLConnection object.
Step 2 - Instantiate a new MySQLCursor object from the MySQLConnection object by calling the cursor() method.
Step 3 - Call callproc() method of the MySQLCursor object. You pass the stored procedure’s name as the first argument of the callproc() method. If the stored procedure requires parameters, you need to pass a list as the second argument to the callproc() method. In case the stored procedure returns a result set, you can invoke the stored_results() method of the MySQLCursor object to get a list iterator and iterate this result set by using the fetchall() method.
Step 4 - Close the cursor and database connection as always.
Example :
db_config = read_db_config()
conn = MySQLConnection(**db_config)
cursor = conn.cursor()
cursor.callproc('getEmployee')

All demo files can be present at Github :- https://github.com/codeasitis/Python
**********
To learn Python, start our Python Playlist HERE:
   • Python Basics  

Subscribe to CodeAsItIs:    / codeasitis  

**********
You can write to me at - codeasitis@gmail.com
**********
Connect with us!

Facebook:   / code.asitis.7  
Instagram:   / codeasitis  
Twitter:   / codeasitis1  

**********

Thank you!
CodeAsItIs


Sur cette page du site, vous pouvez voir la vidéo en ligne Python MySQL Tutorials | Handling Stored Procedures in Python | Python Procedures | MySQL in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur CodeAsItIs 27 novembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 4,130 fois et il a aimé 53 téléspectateurs. Bon visionnage!