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

Fix dbrestore of sqlite database to like newlines #258

Closed
wants to merge 2 commits into from

Conversation

rgaiacs
Copy link
Contributor

@rgaiacs rgaiacs commented Aug 18, 2017

Related to #238.

On Textfields that have line breaks, sqlite reports "unrecognized token"
because it doesn't keep the previous line in memory to be ammended by
the current line.

This pull requests implements a very simple logic to only send SQL
INSERT commands when the line finished with ");".

Closes #254

@ZuluPro
Copy link
Contributor

ZuluPro commented Aug 19, 2017

Hi @rgaiacs
Very great work, could you just add unit test to ensure your PR ?

@ZuluPro ZuluPro self-assigned this Aug 19, 2017
@ZuluPro ZuluPro added database db/sqlite bug Bugs that need to get fixed. labels Aug 19, 2017
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Aug 21, 2017

Hi @ZuluPro, could you help me with the unit test? I'm not sure if dbbackup/tests/commands/test_dbrestore.py is the file that I need to edit.

@ZuluPro
Copy link
Contributor

ZuluPro commented Aug 22, 2017

Hello @rgaiacs
There are the following things to do:

  • Create a model for TextField in dbbackup.tests.testapp.models.TextModel
  • Add a specific test using TextField in dbbackup.tests.test_connectors. SqliteConnectorTest. test_restore_dump_with_textarea_and_newline

Thank you very much !

@ZuluPro
Copy link
Contributor

ZuluPro commented Oct 1, 2017

Hello @rgaiacs
Any news ?

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Oct 2, 2017

Any news ?

Still trying to write the tests. Unit tests isn't my strongest skill. :-(

@rgaiacs
Copy link
Contributor Author

rgaiacs commented Oct 16, 2017

@ZuluPro I try to do as instructed but I'm receiving

sqlite3.OperationalError: no such table: testapp_textmodel
~~~

@ZuluPro
Copy link
Contributor

ZuluPro commented Oct 16, 2017

@rgaiacs
Thanks for you work.
Did you do the makemigrations ?

On Textfields that have line breaks, sqlite reports "unrecognized token"
because it doesn't keep the previous line in memory to be ammended by
the current line.

This pull requests implements a very simple logic to only send SQL
INSERT commands when the line finished with ");".

Close jazzband#238
@rgaiacs
Copy link
Contributor Author

rgaiacs commented Oct 17, 2017

Did you do the makemigrations ?

I didn't. I executed makemigrations and get some UserWarning when running the unittests. Can you have a look and provide feedback. Thanks very much for your help.

@ZuluPro
Copy link
Contributor

ZuluPro commented Oct 17, 2017

@rgaiacs
What is your UserWarning ? Is it a SQLite one ?
Could you just test the integrity of the data, if after restore "foo\nbar" is the same ?

@ZuluPro
Copy link
Contributor

ZuluPro commented Dec 16, 2017

@rgaiacs Any news ?

@jonathan-s jonathan-s added needs tests and removed bug Bugs that need to get fixed. database labels Sep 20, 2020
@Lokkook
Copy link
Contributor

Lokkook commented Nov 27, 2020

Hi !
@ZuluPro, @jonathan-s : Is this merge request planned? Seems pretty useful 👍
thanks!

@dtasev
Copy link

dtasev commented Apr 10, 2021

@Lokkook I wouldn't rely on it, it seems #258 has been long abandoned despite the work being there and just needing a test. Unfortunate, it seems like a great tool but if it doesn't work for the simplest case of SQLite, it's not going anywhere near production

@ZuluPro
Copy link
Contributor

ZuluPro commented Apr 11, 2021

@rgaiacs @Lokkook @dtasev
The PR isn't in mergeable state.

@dtasev
Copy link

dtasev commented Apr 14, 2021

I agree, this PR is quite old so it's likely the project has moved quite a bit forward. It just seemed a shame as, at least from the comments, it sounds like it was somewhat close to being done in 2017. If people happen to come across this issue, this was my solution for SQLite in the end:

To dump the db & encrypt it:

manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission > dbdump.json
gpg --passphrase $PASSPHRASE --quiet --batch --yes -c dbdump.json && rm dbdump.json

To restore:

gpg --passphrase $PASSPHRASE --quiet --batch --yes dbdump.json.gpg
manage.py loaddata dbdump.json

This was referenced Jan 9, 2022
@demonhunter3333
Copy link

it's crazy that this package doesn't even work with SQLite😢

@Archmonger
Copy link
Contributor

Hey @demonhunter3333

I took over this project not too long ago. I'm aware of several issues with the current design, and am proposing an overhaul to fix them. See the following for more info:

@Archmonger Archmonger added bug Bugs that need to get fixed. restore and removed needs tests api/restore labels Apr 28, 2022
@Archmonger
Copy link
Contributor

Archmonger commented Apr 28, 2022

Closing in favor of

@Archmonger Archmonger closed this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs that need to get fixed. db/sqlite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't restore database if field has a line break
7 participants