PostgreSQL Destination
The platform supports connections tp PostgreSQL resources used as destinations.
Turbine Code Examples
Once you have configured a PostgreSQL resource, you can use it as a destination in your streaming application by using the resources
and write
methods in your Turbine code.
In this example, the PostgreSQL Resource is named named pg_db
. We want to write data to the users
table. If you have a schema other than public
, you'll need to indicate that like so: schema_name.users
.
- JavaScript
- Python
- Go
- Ruby
exports.App = class App {
async run(turbine) {
let destination = await turbine.resources("pg_db");
await destination.write("users");
}
};
To learn more about how to use these Turbine methods to stream data from a Turbine streaming application to your PostgreSQL destination using JavaScript, check out the Turbine App Overview for JavaScript.
class App:
@staticmethod
async def run(turbine: Turbine):
destination = await turbine.resources("pg_db")
await destination.write("users")
To learn more about how to use these Turbine methods to stream data from a Turbine streaming application to your PostgreSQL destination using Python, check out the Turbine App Overview for Python.
package main
func main() {
runner.Start(App{})
}
var _ turbine.App = (*App)(nil)
type App struct{}
func (a App) Run(v turbine.Turbine) error {
destination, err := v.Resources("pg_db")
if err != nil {
return err
}
err = destination.Write("users")
if err != nil {
return err
}
return nil
}
To learn more about how to use these Turbine methods to stream data from a Turbine streaming application to your PostgreSQL destination using Go, check out the Turbine App Overview for Go.
# frozen_string_literal: true
require "rubygems"
require "bundler/setup"
require "turbine_rb"
class MyApp
def call(app)
destination = app.resource(name: "pg_db")
destination.write(records: records, collection: "users")
end
end
To learn more about how to use these Turbine methods to stream data from a Turbine streaming application to your PostgreSQL destination using Ruby, check out the Turbine App Overview for Ruby.