python - Inserting user data with stored procedure gives error when committing -


this code gives error on conn.commit line.

error: ('hy000', "[hy000] [mysql][odbc 3.51 driver]commands out of sync; can't run command (2014) (sqlendtran)") 

whenever call sp id keep increasing in table record not inserting.

@app.route("/insert_user") def insert_user():             try:         conn = pyodbc.connect("driver={/usr/local/lib/libmyodbc3.so};server=localhost;database=user_data;user=user;password=user_pass;option=3;autocommit = true")         cur = conn.cursor()         cur.execute("{call insert_user_sp(0,'aby@gmail.com','345','male','1992-01-12','www.facebook.com','abc','xyz','p','jr','english','i student')}")         conn.commit()      except error e:         print e      finally:         cur.close()         conn.close() 

since you're using mysql on linux, recommend using mysql python package rather pyodbc. use pyodbc connecting microsoft sql server, package when using mysql:

https://pypi.python.org/pypi/mysqlclient

then can use cursor.callproc():

http://mysqlclient.readthedocs.org/en/latest/user_guide.html?highlight=callproc#cursor-objects

good luck!


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -