Python connect to PostgreSQL / TimescaleDB

Robert Diers
Aug 7, 2022

--

Here you can find an easy example to handle database connectivity in Python (used with TimescaleDB to save metrics):

I hardcoded my table name, but I think you can get the approach :-)

#connect to database
TimescaleDb.connect(timescaledb_ip, timescaledb_username, timescaledb_password)
#write a single metric value (hardcoded table)
TimescaleDb.write('my_id', my_value)
#read value from a table (in this case without where)
TimescaleDb.read('my_single_value_table')
#increase value of the table (in this case without where)
TimescaleDb.increase('my_single_value_table', addition, max_value)

--

--