Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- db = MySQLdb.connect(db='service')
- c = db.cursor()
- c.execute("""DELIMITER //
- CREATE FUNCTION trivial_func (radius float)
- RETURNS FLOAT
- BEGIN
- IF radius > 1 THEN
- RETURN 0.0;
- ELSE
- RETURN 1.0;
- END IF;
- END //
- DELIMITER ;""")
- Traceback (most recent call last):
- File "proof.py", line 21, in <module>
- DELIMITER ;""")
- File "build/bdist.macosx-10.5-i386/egg/MySQLdb/cursors.py", line 173, in execute
- File "build/bdist.macosx-10.5-i386/egg/MySQLdb/connections.py", line 35, in defaulterrorhandler
- _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")
- CREATE FUNCTION trivial_func (radius float)
- RETURNS FLOAT
- BEGIN
- IF radius > 1 THEN
- RETURN 0.0; <-- does this semicolon terminate RETURN or CREATE FUNCTION?
- ELSE
- RETURN 1.0;
- END IF;
- END
Add Comment
Please, Sign In to add comment