API
  • API Index
  • Batch API
  • Content Negotiation
  • Dynamic Paths
  • Hierarchy API
  • List API
  • Quick Reference
  • Time Series API
  • Views
    • Configuration
  • Overview
  • Application Configuration
  • Documentation Configuration
  • Spec Configuration
    • Features
  • API Testing
  • Asynchronous Processing
  • Cassandra Time-Series Engine
  • Cassandra Integration
  • Default Controller Customisation
  • Documentation
  • Geospatial Filtering
  • Model Documentation
  • PostgreSQL Integration
  • Excel Spreadsheet Format
    • Tutorials
  • Step-by-Step Guide
  • Archetype Setup
  • Logging
  • Prometheus
  • Sentry Logging
    • UI Customisation
  • UI Customisation
  • SASS Build Chain
  • Shared Layout
  • API Documentation
  • Model Documentation
  • Results
  • sapi-nt v current

    PostgreSQL Integration

    You can use a PostgreSQL database as a data store in your sapi-nt application.

    Before configuring your integration, you should add the relevant dependencies to your project’s pom.xml. These include the Spring JDBC integration and the JDBC driver of your choice.

    Example

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
      <version>2.2.0.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.2.5</version>
    </dependency>
    

    Data Source

    You can configure a sapi-nt data source which accepts SQL queries.

    Time series endpoints can use a PostgreSQL database as their data source.

    SQL data source specs have a type of dataSource.sql, and require no further configuration in the spec file. The underlying data source is configured by the Spring framework, using properties that are set in your application configuration (eg. application.yaml). These properties configure the SQL database connection and other parameters, including authentication. See the example below for a minimal configuration.

    Example

    name     : tsDataSource
    type     : dataSource.sql
    
    # application.yaml
    spring:
      datasource:
        platform: postgres
        driverClassName: org.postgresql.Driver
        url: jdbc:postgresql://localhost:5432/dbname
        username: postgres
        password: password
    

    Note

    Since the SQL data source uses the same auto-configuration as armlib integration, it is not possible to use both features on separate databases in a single sapi-nt application. This may be addressed in a future release.