Python3 connects to the Mairadb database and python3mairadb

Source: Internet
Author: User

Python3 connects to the Mairadb database and python3mairadb

<Span style = "font-size: 18px;"> # This Code demonstrates connecting to the Mairadb database under python3.3.5. </span>
<Span style = "font-size: 18px;"> import mysql. connectorconfig = {'host': '2017. 168.14.101 ', # default 127.0.0.1 'user': 'person', 'Password': '000000', 'Port': 123456, # default value: 3306 </span>
<Span style = "font-size: 18px;"> <span style = "white-space: pre "> </span> # If the default value is 3306, you do not need to use 'database': 'one', 'charset ': 'utf8' # utf8 by default} try: cnn = mysql. connector. connect (** config) print ('Connection successfully') Doesn't mysql. connector. error as e: print ('connect fails! {} '. Format (e) </span>

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.