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

Can't restore database if field has a line break #254

Closed
rgaiacs opened this issue Jul 18, 2017 · 1 comment · Fixed by #383
Closed

Can't restore database if field has a line break #254

rgaiacs opened this issue Jul 18, 2017 · 1 comment · Fixed by #383
Assignees
Labels
bug Bugs that need to get fixed. db/sqlite

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented Jul 18, 2017

For SQLite, the restore function is

    def restore_dump(self, dump):
        if not self.connection.is_usable():
            self.connection.connect()
        cursor = self.connection.cursor()
        for line in dump.readlines():
            try:
                cursor.execute(line.decode('UTF-8'))
            except OperationalError as err:
                warnings.warn("Error in db restore: {}".format(err))
            except IntegrityError as err:
                warnings.warn("Error in db restore: {}".format(err))

The function will not performer as expected if one field has a line break because the SQL instruction will be truncate.

From the issue #238

I get a UserWarning when running dbrestore for an sqlite database:

UserWarning: Error in db restore: unrecognized token:
And then a print of some text I have entered in a field. This only happens on Textfields that have line breaks. The rest of the db restore seems to work as expected.

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

ZuluPro commented Jul 18, 2017

Related to #238

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
4 participants