I am using IBM Cloud Functions to convert the audio file into text and I am using IBM Watson speech to text service for that. Here I want to store the transcript to PostgreSQL Database. Is there any connection between IBM Cloud Functions and Compose for PostgreSQL service, So that I can store transcript to database.
I am using Node Runtime in cloud function.
Using the Node.js module pg that is included in the Cloud Functions runtime works well. The following is a function stub that works for me ( taken from this GitHub repo ):
function myactualfunc(connection, some params) {
const client=new Client({
connectionString: connection['postgres']['composed'][0],
ssl: true
});
return client.connect()
.then(() =>
client.query(
"select ....",
query-parameters))
.then(res => perform some processing here)
.then(() => client.end())
.then(() => {return {"result": my-result} })
.catch(e => {return {"error": e}})
}
function main({some params, __bx_creds: {'databases-for-postgresql': {connection}}}) {
return myactualfunc(connection,some params);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.