Python connect to PostgreSQL / TimescaleDB

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)

--

--

IT Architect

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store