lathonez / clone-row

Python utility to clone a row in mysql, from a target to source database, field by field
http://lathonez.com/2016/clone-row/
MIT License
7 stars 1 forks source link

UnicodeDecodeError when attempting restore during local->prod clone #12

Closed jonclow closed 7 years ago

jonclow commented 7 years ago

Trace: DEV:~/code/wherewolf-client$ CloneRow.py local prod client pool heliviewtaranaki 2017-07-03 01:17:21 Reading configuration.. 2017-07-03 01:17:21 The following columns will be ignored: id createdAt updatedAt last_guest last_login 2017-07-03 01:17:21 attempting to connect to local.. 2017-07-03 01:17:21 connected to root@local:wherewolf - Database version : 90601 2017-07-03 01:17:21 attempting to connect to prod.. 2017-07-03 01:17:23 connected to jon@prod:wherewolf - Database version : 90602 2017-07-03 01:17:23 getting local row.. 2017-07-03 01:17:23 getting prod row.. 2017-07-03 01:17:23 checking encoding.. 2017-07-03 01:17:23 source encoding UTF8 2017-07-03 01:17:23 target encoding UTF8 2017-07-03 01:17:23 finding deltas.. 2017-07-03 01:17:23 2017-07-03 01:17:23 |--------------------------------|Data Changes|--------------------------------| 2017-07-03 01:17:23 The following columns will be updated on prod 2017-07-03 01:17:23 -operators_review_guests_view 2017-07-03 01:17:23 -where_hear 2017-07-03 01:17:23 |------------------------------------------------------------------------------| 2017-07-03 01:17:23 2017-07-03 01:17:23 backing up target row.. 2017-07-03 01:17:24 backup file can be found at /tmp/client-pool-heliviewtaranaki-1499044641113.backup on this machine 2017-07-03 01:17:24 dumping update sql to disk.. 2017-07-03 01:17:24 update sql is available for inspection at /tmp/client-pool-heliviewtaranaki-1499044641113.sql on this machine 2017-07-03 01:17:24 Row has been cloned successfully.. 2017-07-03 01:17:24 Type 'r' to (r)estore from backup, anything else to exit r 2017-07-03 01:19:07 restoring from backup.. Traceback (most recent call last): File "/home/wherewolf/clone-row/CloneRow.py", line 681, in if DOLLY.user_happy(): File "/home/wherewolf/clone-row/CloneRow.py", line 657, in user_happy self._restore_target() File "/home/wherewolf/clone-row/CloneRow.py", line 316, in _restore_target ret = self.target['connection'].load(self.target['backup'], self.database['table']) File "/home/wherewolf/clone-row/PDBC.py", line 315, in load cur.copy_from(handle, table) psycopg2.extensions.QueryCanceledError: COPY from stdin failed: error in .read() call: UnicodeDecodeError 'ascii' codec can't decode byte 0xe2 in position 1195: ordinal not in range(128) CONTEXT: COPY client, line 1

jonclow commented 7 years ago

PDBC.py line 311. Does this need an encoding added to prevent psycopg2 defaulting to ascii?

lathonez commented 7 years ago

@jonclow - thanks a lot for putting the time into this.

In case it isn't obvious, this repo is open to the world and isn't (intended) to be wherewolf specific. All comments so far are fine, but be careful with SQL.

The last two commits we've made here were to address similar issues:

I have replicated this locally, so there is no need to provide anything additional.

Re 311 quite probably.

I will take a look at this, no need for you to do anything else.

Thanks again.

lathonez commented 7 years ago

replicated just be changing assets_version

lathonez commented 7 years ago

closed

9777e78