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

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.

主站蜘蛛池模板: 青浦区| 英德市| 安西县| 桂阳县| 广安市| 盐津县| 深水埗区| 富裕县| 新昌县| 汉沽区| 肃宁县| 马尔康县| 博罗县| 建阳市| 卢龙县| 曲周县| 丹巴县| 海阳市| 西贡区| 阳信县| 沙河市| 高唐县| 仁寿县| 阿图什市| 济源市| 怀仁县| 澄江县| 肇东市| 邵东县| 嘉义县| 阳泉市| 连云港市| 合川市| 杭锦后旗| 惠来县| 翁源县| 黎平县| 裕民县| 平顺县| 宁陕县| 尼勒克县|