Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of reading database data in python operation database

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Automated tests often write data to the database and then read it from the database.

Here's how to read data from a database.

Prerequisite: mysql.connector module is installed

The established database is (under the tet table of the test database):

Use fetchone () to get the next row of the result set

The values read after running are:

If you add a statement C = fetchone () directly after D, C will be the next value in the list:

The value of C obtained is:

And so on, continuing with fetchone will continue to read the next row of data in the result set.

Use fetchall () to get all the remaining rows in the result set

The values read after running are:

Third, use fetchmany () to get the lower line of the result set (specify how many rows of data are printed)

The running result will get 2 rows of data results:

There is a problem QQ × × stream 610845268

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report