官术网_书友最值得收藏!

How it works

Accessing a MySQL database using the mysql.connector involves the use of two classes from the library: connect and cursor. The connect class opens and manages a connection with the database server.  From that connection object, we can create a cursor object.  This cursor is used for reading and writing data using SQL statements.

In the first example, we used the cursor to insert nine records into the database. Those records are not written to the database until the commit() method of the connection is called.  This executes the writes of all the rows to the database.

Reading data uses a similar model except that we execute an SQL query (SELECT) using the cursor and iterate across the rows that were retrieved. Since we are reading and not writing, there is no need to call commit() on the connection.

主站蜘蛛池模板: 嘉定区| 荔波县| 静海县| 宜章县| 吐鲁番市| 广元市| 乐山市| 新巴尔虎左旗| 兴仁县| 赤水市| 疏勒县| 肇源县| 达拉特旗| 涞水县| 阳春市| 麟游县| 临泽县| 凭祥市| 社会| 莆田市| 肃北| 鹤峰县| 龙江县| 天等县| 九江县| 太仓市| 定西市| 武宣县| 红河县| 景德镇市| 东兰县| 洪洞县| 门源| 山阴县| 长丰县| 东平县| 勐海县| 石嘴山市| 乐亭县| 阿鲁科尔沁旗| 贵南县|