Guest User

Untitled

a guest
Jun 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import MySQLdb
  2.  
  3. db = MySQLdb.connect(db='service')
  4.  
  5. c = db.cursor()
  6.  
  7. c.execute("""DELIMITER //
  8. CREATE FUNCTION trivial_func (radius float)
  9. RETURNS FLOAT
  10.  
  11. BEGIN
  12. IF radius > 1 THEN
  13. RETURN 0.0;
  14. ELSE
  15. RETURN 1.0;
  16. END IF;
  17. END //
  18.  
  19. DELIMITER ;""")
  20.  
  21. Traceback (most recent call last):
  22. File "proof.py", line 21, in <module>
  23. DELIMITER ;""")
  24. File "build/bdist.macosx-10.5-i386/egg/MySQLdb/cursors.py", line 173, in execute
  25. File "build/bdist.macosx-10.5-i386/egg/MySQLdb/connections.py", line 35, in defaulterrorhandler
  26. _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER //nCREATE FUNCTION trivial_func (radius float) n RETURNS FLOATnn ' at line 1")
  27.  
  28. CREATE FUNCTION trivial_func (radius float)
  29. RETURNS FLOAT
  30.  
  31. BEGIN
  32. IF radius > 1 THEN
  33. RETURN 0.0; <-- does this semicolon terminate RETURN or CREATE FUNCTION?
  34. ELSE
  35. RETURN 1.0;
  36. END IF;
  37. END
Add Comment
Please, Sign In to add comment