# Logstash and databse

**URL:** <https://discuss.elastic.co/t/logstash-and-databse/26225>\
**Category:** Logstash\
**Created:** [July 24, 2015, 10:24am UTC](https://discuss.elastic.co/t/logstash-and-databse/26225 "2015-07-24T10:24:22Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [July 29, 2015, 5:18am UTC](https://discuss.elastic.co/t/logstash-and-databse/26225/4 "2015-07-29T05:18:04Z")

</div>

For now. you may want to take a look at the `:sql_last_start` computed parameter. This field represents the last time (in current time) for which a sql statement was run. So if your timestamps are based on real time as well, this may work for you.

you can set it up like this:

```auto
input {
  jdbc {
    ...
    statement => "select * from table where timestamp > :sql_last_start"
    schedule => "* * * * *"
  }
}

```

This input configuration will only fetch latest records and run according to this cron-like schedule which means "run every minute, on the minute". By adding a schedule, the input plugin will stay alive and run the query every minute.

Regarding postgresql. this plugin supports that. You just have to download the driver jars yourself from here: [https://jdbc.postgresql.org/download.html](https://jdbc.postgresql.org/download.html). and configure the `jdbc_driver_library` with the path of the downloaded driver. And set the `jdbc_driver_class` option to `org.postgresql.Driver`.

does that make sense? for a number of reasons, we chose not to include these jars within the plugin itself.

---

_[View the full topic](https://discuss.elastic.co/t/logstash-and-databse/26225)._
