Operation of the database stored procedure pymysql

#_author: to child star 
#date: 2020/3/11
# stored procedure
Import pymysql
Conn = pymysql.connect (Host = '127.0.0.1', = User 'the root', the passwd = '123', DB = 'DB1', = charset 'UTF8')
Cursor = conn.cursor (pymysql.cursors.DictCursor = Cursor)
# execute a stored procedure: (1) obtain a result set stored procedures, (2) returns to the setting value stored procedure names _ _ No.
R1 = cursor.callproc ( 'P11', args = (1,22,3,4))
Print (R1)
result0 = cursor.fetchall ()
Print (result0)
# executing the acquisition parameters stored
r2 = cursor.execute ( "SELECT @ _p11_0, @ _ P11_1, @ _ p11_2, @ _ p11_3")
# @ _p11_0 =. 1
# @ _p11_1 = 22 is
# @ _p11_2 =. 3
# @ _p11_3 =. 4
Print (R2)
Result = cursor.fetchall ()
Print (Result )

conn.commit ()
cursor.close ()
conn.Close ()

Guess you like

Origin www.cnblogs.com/startl/p/12466481.html