Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

Add export option #7

Merged
merged 3 commits into from
Sep 24, 2019
Merged

Add export option #7

merged 3 commits into from
Sep 24, 2019

Conversation

fdev
Copy link
Owner

@fdev fdev commented Sep 23, 2019

Fixes #6

This PR adds export functionality. You can export specific tables (using --export or -E) or opt to export all the tables (using --export-all or -A).

@centic9 @completementgaga Could you verify this code works for both your installations?

@centic9
Copy link

centic9 commented Sep 23, 2019

Thanks for the work, for me Python reported the following when I tried to paste the output into a file via simple redirection:

FATAL ERROR: 'ascii' codec can't encode character u'\xe4' in position 7423: ordinal not in range(128)

Setting the following environment variable made it work, so it seems to be some general Python issue with my local UTF-8 encoding and Unicode characters in my SQL database.

PYTHONIOENCODING=UTF-8

Otherwise it works fine now for me.

@completementgaga
Copy link

Good night,
I tried to run this branch's version with the -A flag.
I got a bunch of what is I believe is sql code in the terminal. I copy&pasted to a file. I tried to import it in a local database (with phpMyadmin GUI), it seemed to work with 242 queries executed. With the exported database from phpMyadmin GUI, 347 queries are executed. the results look similar in local phpmyadmin's GUI
I will investigate tomorrow if both results are equal in phpmyadmin.
However, when trying to export the database to a file ending the command with > database1.sql, I got the same FATAL ERROR message as @centic9.

I am confident I am in the right direction with phpmyadmin-cli to back-up my database.

Thanks to both of you. My university's web hosting service makes every day April's fools day, forbidding the normal use of mysql for back-ups.

Best,

@fdev
Copy link
Owner Author

fdev commented Sep 23, 2019

Thanks for the feedback, both of you. I'll look into the encoding error tomorrow.

The difference in number of queries might be because of different export settings, which cause for example INSERT statements to be grouped.

@fdev
Copy link
Owner Author

fdev commented Sep 24, 2019

On my system I couldn't reproduce the fatal error, everything exports just fine here. 😕

I did make a change to ensure the encoding is utf-8 when the export is written to stdout. Did this fix the error?

@centic9
Copy link

centic9 commented Sep 24, 2019

I think it only happened to me when I redirected the output into a file via " > /tmp/test.sql", not sure what different this makes.

Anyway, the latest version from the branch works also in that case, so the change seems to work fine now.

@fdev
Copy link
Owner Author

fdev commented Sep 24, 2019

I tried output redirection to a file as well, but the previous code still works for me. Maybe it's because of a different database collation, or the fact my terminal locale is already set to unicode.

Nevertheless, good to hear the latest version works!
If it also works for @completementgaga I'll merge this code into master.

@completementgaga
Copy link

Good night,
It works well for me to! Thank you very much Folkert!

Best,

@fdev fdev merged commit 0d4fe3d into master Sep 24, 2019
@fdev fdev deleted the feature/export branch September 24, 2019 20:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to export database contents to sql
3 participants