Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return " ProgrammingError: execute() first" in sql_error_handler #718

Closed
Funnyhao opened this issue Sep 23, 2015 · 5 comments
Closed

return " ProgrammingError: execute() first" in sql_error_handler #718

Funnyhao opened this issue Sep 23, 2015 · 5 comments

Comments

@Funnyhao
Copy link

class MyMYSQL(MySQLDatabase):

def sql_error_handler(self,exception,sql,params,require_commit):
    db.close();
    db.connect();
    db.execute_sql(sql, params or (), require_commit = require_commit);

    return False;

I find test sql_error_handler with kill mysql process but it gets :

  File "/data1/wejobssvr/handler/base.py", line 64, in get
    result = self._do(args);
  File "/data1/wejobssvr/handler/main.py", line 75, in _do
    result = getattr(op_controller, action_type, self.error_result)(params);
  File "/data1/wejobssvr/controller/oneoff_controller.py", line 489, in get_job
    job_meta = JobMetaInfo.get(id=int(params_dict["job_meta_id"]));
  File "/data1/wejobssvr/client/../util/peewee.py", line 3395, in get
    return sq.get()
  File "/data1/wejobssvr/client/../util/peewee.py", line 2383, in get
    return clone.execute().next()
  File "/data1/wejobssvr/client/../util/peewee.py", line 1686, in next
    obj = self.iterate()
  File "/data1/wejobssvr/client/../util/peewee.py", line 1667, in iterate
    row = self.cursor.fetchone()
  File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 365, in fetchone
    self._check_executed()
  File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 105, in _check_executed
    self.errorhandler(self, ProgrammingError, "execute() first")
  File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: execute() first
@coleifer
Copy link
Owner

I don't see how this is a bug in peewee.

@Funnyhao
Copy link
Author

it's not possible to allow returning a new cursor to execute_sql when "Mysql gone away" happens?

@coleifer
Copy link
Owner

Hmm, that would change the contract of the function and I'm not sure I'd like to make the change.

I do see, though, how returning the old cursor from before the reconnect is causing the issue.

@coleifer
Copy link
Owner

See 017e4e4 for a fix.

@Funnyhao
Copy link
Author

Funnyhao commented Oct 5, 2015

thx a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants