【发布时间】:2021-04-28 14:51:42
【问题描述】:
我正在使用pymysql 执行一些sql 插入查询。我正在使用LOAD DATA INFILE,它工作正常。
通常当您运行 SQL 查询时,它会在底部打印行数和时间。如果它是SELECT 查询,它将打印它之前的表。我知道一些有助于打印表格的第三方库。我正在寻找一种方法来打印包含行数和时间的最后一行。
这是一个示例 -
MySQL localhost:33060+ ssl world_x JS > shell.options.set('resultFormat','table')
MySQL localhost:33060+ ssl world_x JS > session.sql("select * from city where countrycode='AUT'")
+------+------------+-------------+---------------+-------------------------+
| ID | Name | CountryCode | District | Info |
+------+------------+-------------+---------------+-------------------------+
| 1523 | Wien | AUT | Wien | {"Population": 1608144} |
| 1524 | Graz | AUT | Steiermark | {"Population": 240967} |
| 1525 | Linz | AUT | North Austria | {"Population": 188022} |
| 1526 | Salzburg | AUT | Salzburg | {"Population": 144247} |
| 1527 | Innsbruck | AUT | Tiroli | {"Population": 111752} |
| 1528 | Klagenfurt | AUT | Kärnten | {"Population": 91141} |
+------+------------+-------------+---------------+-------------------------+
6 rows in set (0.0030 sec)
我想使用pymysql 打印6 rows in set (0.0030 sec)。我已经尝试过使用EXPLAIN,但这仅适用于SELECT 命令。我试过使用fetchone()、fetchall()、fetchmany(),但没有成功。
【问题讨论】: