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 8441733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:38:33+00:00 2026-06-10T08:38:33+00:00

I use scrapy to take information from a website that according to w3 validator

  • 0

I use scrapy to take information from a website that according to w3 validator is utf-8..

My python project has

# -*- coding: utf-8 -*-

I receive some names like López J and when I print it, it shows fine…

But when I want to store it into the mysql I get some error about ascii not being able to encode blah blah blah…

If I use .encode ('ascii', 'ignore') i get: Lpez J
If I use .encode ('ascii', 'replace') i get: López J
if I use .encode ('utf-8') i get: López J

What should I do?
I’m in a big trouble here :'(

  • 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-10T08:38:35+00:00Added an answer on June 10, 2026 at 8:38 am

    When you connect to the database use charset='utf-8', use_unicode=True with other keywords to connect() method. This should make the dababase accept and return unicode values, so you don’t have to (and shouldn’t) encode them manually.

    Example:

    >>> import MySQLdb
    >>> conn = MySQLdb.connect(... , use_unicode=True, charset='utf8')
    >>> cur = conn.cursor()
    >>> cur.execute('CREATE TABLE testing(x VARCHAR(20))')
    0L
    >>> cur.execute('INSERT INTO testing values(%s)', ('López J',))
    1L
    >>> cur.execute('SELECT * FROM testing')
    1L
    >>> print cur.fetchall()[0][0]
    López J
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the Python Scrapy module to scrape all the URLs from
I'm trying to use Scrapy to scrape the U.S. government regulations website (www.regulations.gov). It's
I've written a Scrapy spider that extracts text from a page. The spider parses
I've deployed a scrapy project, linked with a class which use MySQLdb (for persistence
I want to use greasemonkey to scrape wiki data from Last.fm (this is not
In answer to a previous question , several people suggested that I use BeautifulSoup
I was trying to use a WebBrowser to scrape this website and tried to
I am trying to use the HTML Agility pack to scrape some data from
I scrape some sites that occasionally have UTF-8 characters in the title, but that
I use the XML and RCurl packages of R to get data from a

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.