Skip to content

update cos-to-sql example #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cos-to-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ Install `jq`. On MacOS, you can use following [brew formulae](https://formulae.b
* Create the service credential to access the PostgreSQL instance
```
SM_SECRET_FOR_PG_NAME=pg-access-credentials
ibmcloud secrets-manager secret-create \
ibmcloud secrets-manager config set instance-id $SM_INSTANCE_GUID
ibmcloud secrets-manager config set region $REGION
ibmcloud secrets-manager config set service-url https://$SM_INSTANCE_GUID.$REGION.secrets-manager.appdomain.cloud
SM_SECRET_FOR_PG_ID=$(ibmcloud secrets-manager secret-create \
--secret-type="service_credentials" \
--secret-name="$SM_SECRET_FOR_PG_NAME" \
--secret-source-service="{\"instance\": {\"crn\": \"$DB_INSTANCE_ID\"},\"parameters\": {},\"role\": {\"crn\": \"crn:v1:bluemix:public:iam::::serviceRole:Writer\"}}"

SM_SECRET_FOR_PG_ID=$(ibmcloud sm secret-by-name --name $SM_SECRET_FOR_PG_NAME --secret-type service_credentials --secret-group-name default --instance-id $SM_INSTANCE_GUID --region $REGION --output JSON|jq -r '.id')
--secret-source-service="{\"instance\": {\"crn\": \"$DB_INSTANCE_ID\"},\"parameters\": {},\"role\": {\"crn\": \"crn:v1:bluemix:public:iam::::serviceRole:Writer\"}}" \
--output JSON|jq -r '.id')
```

* Create the Code Engine app:
Expand Down
2 changes: 1 addition & 1 deletion cos-to-sql/utils/db.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function deleteUsers(client) {
const startTime = Date.now();
console.log(`${fn} >`);
return new Promise(function (resolve, reject) {
const queryText = "DROP TABLE users";
const queryText = "DELETE * FROM users";
client.query(queryText, undefined, function (error, result) {
if (error) {
console.log(`${fn} < failed - error: ${error}; duration ${Date.now() - startTime} ms`);
Expand Down