python - 如何获取 postgres 游标的执行时间(python)
问题描述
我想在得到结果后获取光标的执行时间,基本上需要在 postgres sql 中执行查询,并在我的日志中记录在 postgres sql server 端执行查询所花费的时间。
试图实现这样的事情:
import psycopg2
import pandas as pd
conn = psycopg2.connect(host="localhost",database="shrek", user="postgres", password="apple")
print(conn)
cur = conn.cursor()
abc =cur.execute('select id from company')
result = cur.fetchone()
print(result[0])
print(cur.fetchtime())-------> i want to print the execution time
解决方案
推荐阅读
- python - Spyder:无法关闭正在运行的事件循环
- python - 如何从这两个字符串中提取字符串信息?
- ios - 无法将苹果帐户添加到 Visual Studio 2017
- swift5 - 快速删除文本字段末尾的空格
- flutter - 最近升级到新版本的 Flutter(v1.12.13+hotfix.8) 和其他库后,应用程序不断崩溃
- angular - 操作员使用拦截器时如何延迟等待承诺响应
- google-cloud-platform - 在云 sdk shell 中安装 ApacheBeam 时出错
- mongodb - 过滤在一组日期发生的交易
- c - 使用 C API 将简单的 JSON 对象插入 SQLite TEXT 列
- angular - 从角度的firestore文档参考中获取数据