【发布时间】:2020-07-19 11:37:59
【问题描述】:
我想使用计数器或任何方法计算表中插入记录的数量,并打印使用 python 脚本运行的每个作业中插入记录的计数。下面给出了示例代码..请建议一些相同的解决方案..
with Postgresql.Database(connection_pool) as db:
--count number of rows inserted in bazaarvoicereviews table and print the count for every job run
db.insert('externaldb.bazaarvoicereviews',data=rdata)
--count number of rows inserted in bazaarvoicereviewsresponses table and print the count for every job run
for rs in _ClientResponses:
db.insert('externaldb.bazaarvoicereviewsresponses',data=rs)
--count number of rows inserted in bazaarvoicereviewscomments table and print the count for every job run
for rc in _ClientComments:
db.insert('externaldb.bazaarvoicereviewscomments',data=rc)
【问题讨论】:
-
你使用哪个 postgressql 包?
-
我们用来加载数据的pyscopg2包
-
我们还创建了自己的模块:Postgresql 将数据加载到表中
标签: python python-3.x postgresql google-cloud-platform google-cloud-sql