Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:38:46+00:00 2026-06-14T09:38:46+00:00

Is there anybody who knows how to solve the next problem? Right now I

  • 0

Is there anybody who knows how to solve the next problem?

Right now I am using this code:

def databasedump(request):
    # Convert file existing_db.db to SQL dump file dump.sql
    con = sqlite3.connect('database.sqlite')
    with open('dump.sql', 'w') as f:  
        for line in con.iterdump():
            f.write('%s\n' % line)

and I get this error:

Exception Type:
UnicodeEncodeError

Exception Value:
‘ascii’ codec can’t encode character u’\xe9′ in position 112: ordinal not in range(128)

The string that could not be encoded/decoded was: (Arivé, PAK

Thanks for looking into this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:38:48+00:00Added an answer on June 14, 2026 at 9:38 am

    There is a bug in the sqlite3 dump code, tracked as issue 15019 in the Python bug tracker.

    You can fix this by editing the sqlite3/dump.py file and adding the following line at the top:

    from __future__ import unicode_literals
    

    Locate the file by running the following command:

    python -c 'import sqlite3.dump; print sqlite3.dump.__file__.rstrip("c")'
    

    You’ll have to adjust the line writing code to encode the unicode values that now will be returned from the .iterdump() method:

    with open('dump.sql', 'w') as f:  
        for line in con.iterdump():
            f.write('%s\n' % line.encode('utf8'))
    

    If you feel uncomfortable with editing the Python standard library source files, use the following (fixed and shortened) function instead:

    def iterdump(connection):
        cu = connection.cursor()
        yield(u'BEGIN TRANSACTION;')
    
        q = """
            SELECT "name", "type", "sql"
            FROM "sqlite_master"
                WHERE "sql" NOT NULL AND
                "type" == 'table'
            """
        schema_res = cu.execute(q)
        for table_name, type, sql in sorted(schema_res.fetchall()):
            if table_name == 'sqlite_sequence':
                yield(u'DELETE FROM "sqlite_sequence";')
            elif table_name == 'sqlite_stat1':
                yield(u'ANALYZE "sqlite_master";')
            elif table_name.startswith('sqlite_'):
                continue
            else:
                yield(u'{0};'.format(sql))
    
            table_name_ident = table_name.replace('"', '""')
            res = cu.execute('PRAGMA table_info("{0}")'.format(table_name_ident))
            column_names = [str(table_info[1]) for table_info in res.fetchall()]
            q = """SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";""".format(
                table_name_ident,
                ",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names))
            query_res = cu.execute(q)
            for row in query_res:
                yield(u"{0};".format(row[0]))
    
        q = """
            SELECT "name", "type", "sql"
            FROM "sqlite_master"
                WHERE "sql" NOT NULL AND
                "type" IN ('index', 'trigger', 'view')
            """
        schema_res = cu.execute(q)
        for name, type, sql in schema_res.fetchall():
            yield(u'{0};'.format(sql))
    
        yield(u'COMMIT;')
    

    Use the above like this:

    con = sqlite3.connect('database.sqlite')
    with open('dump.sql', 'w') as f:  
        for iterdump(con):
            f.write('%s\n' % line.encode('utf8'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this problem that i can't solve for days now...here is my code.
Is there anybody who knows the history of appearance of Ctrl + Enter ↵
Is there anybody who knows, what is for, and how it works, the Call
Hi is there anybody who knows how to write the copy command for svn-ant
Is there anybody who knows how to use PJSIP in iOS? What is the
Is there a way to create mysql triggers using Activerecord migrations ? Has anybody
does anybody knows if there is a Jenkins /Hudson plugin that when the build
Is there anybody who can provide a c# example of how to get past
is there any body who knows what javascript plugin that about.me use ? especially
anybody who knows how to change the colors of workbench views (e.g. Package Explorer)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.