How can I write data to Influxdb dynamically?

I need to visualize data from PostgreSQL, for this I wrote a python script that reads the data I need from Postgresql and writes to a text file. I tried using the tail plugin to write data from file to influxdb, but it is not written dynamically. That is, if the contents of the file change, then the new entries will only get into influxdb after restarting telegraf.
How can I write data to Influxdb dynamically?

Can you share your Telegraf configuration file? (Agent and Input section should suffice)