Python MySQL escape Method

Source: Internet
Author: User

Recently, MySQL was used for projects using python.PythonSome of the captured data is stored in MySQL, but there is a problem, because the data captured from the outside has other irregular data such, if you directly call the data insertion method, an error is reported, which is required at this time.
Python MySQL escape.

I started to think that mysqldb does not have a built-in method, and I was planning to filter it myself.AlgorithmLater, I thought that the MySQL module should contain some escape methods, so I kept searching with this belief and found it through the help method and Dir method. It turned out to be: escape_string.

If you want to use the MySQL escape string, you can see the following usage:
Content = mysqldb. escape_string (content)

I have little knowledge. I hope you can help me when you need it. Thank you for your support!

If you are interested in reading the database, you can check it out.Django SQLite database configuration problems

ArticleLink:Http://www.cnpythoner.com/post/163.htmlReprinted and retained. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.