Why did the pymysql execute the SQL statement prompt successfully but did not actually manipulate the database?

Source: Internet
Author: User

Development environment: ANACONDA3+PYCHARM2018

Problem: Using Pymysql to insert data hints successfully, the connection database found no data.

Reason:

Pymysql when connecting to the database, there will be a parameter autocommit default to False, indicating whether to automatically commit to a real database after the execution of the SQL statement, if not set to true, then after you execute SQL, you need to explicitly commit, that is, conn.commit ()。

We can also explicitly assign a value autocommit=true when creating a Connection object for Pymysql.connect (), with all the fields of the Connect () function appended to the end of the text.

code example:

:p Aramhost:host where the database server is located
:p Aramuser:username to log in as
:p AramPassword:password to use.
:p Aramdatabase:database to use, None for use a particular one.
:p AramPort:mysql port to use, default is usually OK. (default:3306)
:p AramBind_address:when The client has multiple network interfaces, specify
The interface from which to connect to the host. Argument can
A hostname or an IP address.
:p Aramunix_socket:optionally, you can use a UNIX socket rather than TCP/IP.
:p AramCharset:charset you want.
:p AramSql_mode:default Sql_mode to use.
:p AramRead_default_file:
Specifies MY.CNF file to read these parameters from under the [Client] section.
:p AramCONV:
Conversion dictionary to use instead of the default one.
This was used to provide custom marshalling and unmarshaling of types.
See Converters.
:p AramUse_unicode:
Whether or not to the default to Unicode strings.
This option defaults to True for py3k.
:p AramClient_flag:custom flags to send to MySQL. Find potential values in constants. CLIENT.
:p AramCursorclass:custom cursor class to use.
:p Araminit_command:initial SQL statement to run when connection is established.
:p AramConnect_timeout:timeout before throwing an exception when connecting.
(Default:10, Min:1, max:31536000)
:p AramSSL:
A dict of arguments similar to Mysql_ssl_set () ' s parameters.
For now the Capath and cipher arguments is not supported.
:p AramRead_default_group:group to read from in the configuration file.
:p AramCompress:not Supported
:p AramNamed_pipe:not Supported
:p Aramautocommit:autocommit mode. None means use server default. (Default:false)
:p AramLocal_infile:boolean to enable the use of the LOAD DATA LOCAL command. (Default:false)
:p AramMax_allowed_packet:max size of packet sent to server in bytes. (DEFAULT:16MB)
Only used to limit size of "LOAD LOCAL INFILE" data packet smaller than default (16KB).
:p AramDefer_connect:don ' t explicitly connect on contruction-wait for connect call.
(Default:false)
:p AramAuth_plugin_map:a Dict of plugin names to A class this processes that plugin.
The class would take the Connection object as the argument to the constructor.
The class needs an Authenticate method taking an authentication packet as
An argument. For the dialog plugin, a prompt (echo, prompt) method can be used
(If no Authenticate method) for returning a string from the user. (experimental)
:p AramDb:alias for database. (For compatibility to MYSQLDB)
:p AramPasswd:alias for password. (For compatibility to MYSQLDB)
:p AramBinary_prefix:add _binary prefix on bytes and bytearray. (Default:false)
"""


Why did the pymysql execute the SQL statement prompt successfully but did not actually manipulate the database?

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.