实时读取txt文件,并使用Python更新postgressql数据库



我有一个包含许多行的txt文件,它正在实时更新。

例如:

001;2021年11月16日;08:00:12;在;123456789;123456;John Doe001;2021年11月16日;09:00:18;OUT;987654321;654321;Jane Doe

我有一个postgrest数据库,我想用第4个数据更新表。

这是我的代码什么是读取文件(a想实时读取,所以这就是我使用while(true(的原因(:

while(True):
Using readlines()
file1 = open('FILE', 'r')
Lines = file1.readlines()
count = 0
for line in Lines:
count += 1
print("Line{}: {}".format(count, line.strip()))

简而言之:我如何通过实时读取文件(在Python中(来更新postgressql表?

对python使用postgres驱动程序,如下所示https://www.psycopg.org/docs/usage.html有很多例子说明如何插入和更新数据

最新更新