Python stop execution

Hi, i have a setup: pi 4b bme680 and are using the python exampel (temperature-pressure-humidity.py) to run it, i need to stop that script after one sec i only need one or a few lines to put into my database every five min., i have tried:
import sys
exit()
sys.exit()
quit()
and they all give:
syntax error
Any good ideas

One way to do it is to add an
import time
at the top, and then do a
time.sleep(secs)
in the while true loop.
time.sleep(300)
is 5 minutes.
And just leave the file running.

Thank you for your answer, i am a python newbee could you please show where to place time.sleep i have done import time on top and done >>>import.time in python3
while True:
if sensor.get_sensor_data():
output = ‘{0:.2f} C,{1:.2f} hPa,{2:.3f} %’.format(
sensor.data.temperature,
sensor.data.pressure,
sensor.data.humidity)
print(output)

Sorry for missing indent in copy/paste

Code tags are three ` at the top and three more at the end of your code.
Try this, you may have to change the indent on the time sleep line, not sure.

#!/usr/bin/env python

import bme680
import time

print("""temperature-pressure-humidity.py - Displays temperature, pressure, and humidity.
If you don't need gas readings, then you can read temperature,
pressure and humidity quickly.
Press Ctrl+C to exit
""")

try:
    sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
except (RuntimeError, IOError):
    sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)

# These oversampling settings can be tweaked to
# change the balance between accuracy and noise in
# the data.

sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)

print('Polling:')
try:
    while True:
        if sensor.get_sensor_data():
            output = '{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH'.format(
                sensor.data.temperature,
                sensor.data.pressure,
                sensor.data.humidity)
            print(output)
            time.sleep(300)

except KeyboardInterrupt:
    pass

It is perfect, thank you very much, i will now pipe the output to a text file for further processing, i have made a bash script to load the database from a text file and run that script by crontab

No problem, glad to help. I usually run those types of files automatically on boot up via crontab.
I have several Enviro+ like builds displaying temp, humidity and pressure.
I don’t send anything to the cloud though, or log the data. I have one setup that graphs to a small LCD so I can see trends. I like to know if the pressure is going up or down etc.