Bench Migrate raises SQL syntax error for backup restore | pymysql.err.ProgrammingError: (1064, u"You have an error in your SQL syntax

Hi! After trying bench migrate, this is the output. My MariaDB is version 10.3, Ubuntu 18, And was trying to install erpnext through this guide. Am I missing something? :frowning:

sudo bench --site erpnext --force migrate
Migrating erpnext
Executing execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2018-02-20 in erpnext (_76cf18db07302d32)
Success: Done in 1.736s
Executing execute:frappe.reload_doc('core', 'doctype', 'docperm') #2018-05-29 in erpnext (_76cf18db07302d32)
Success: Done in 0.676s
Executing frappe.patches.v11_0.copy_fetch_data_from_options in erpnext (_76cf18db07302d32)
Success: Done in 3.278s
Executing frappe.patches.v11_0.replicate_old_user_permissions in erpnext (_76cf18db07302d32)
Success: Done in 20.436s
Executing frappe.patches.v11_0.drop_column_apply_user_permissions in erpnext (_76cf18db07302d32)
Success: Done in 1.449s
Executing frappe.patches.v10_0.refactor_social_login_keys in erpnext (_76cf18db07302d32)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 223, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v10_0/refactor_social_login_keys.py", line 7, in execute
    run_patch()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v10_0/refactor_social_login_keys.py", line 68, in run_patch
    insert_user_social_login(user.name, user.modified_by, 'frappe', idx, userid=user.frappe_userid)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v10_0/refactor_social_login_keys.py", line 117, in insert_user_social_login
    frappe.db.sql(query)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 165, in sql
    self._cursor.execute(query)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'f75d5ece9f'', ''2018-09-26 15:05:59.456646'', ''2018-09-26 15:05:59.456646'', ''' at line 2")

Post made for reference if anybody can solve it.

Also, please mention your erpnext and frappe versions and on which branches so it becomes easier for devs to solve this. This seems like a potential bug

2 Likes

Hey I think your issue has been solved. You should try a bench update. Don’t forget to bench update --patch later
https://github.com/frappe/frappe/pull/6143

2 Likes

Okay! As I needed to get it running quick, I reinstalled using Bitnami’s stack (just because was how I was using it before, at version 10.1.52). But I would like to clean install it without it later this week, so I will be posting here more details!

1 Like