Win $20,000. Help build the future of education. Answer the call. Learn more

IBM Developer Blog

Follow the latest happenings with IBM Developer and stay in the know.

Try sample code to work with SQL Query, Cloud Object Storage, and Cloud Functions

It’s easy to equate serverless computing with functions-as-a-service (FaaS) platforms like OpenWhisk or Lambda, but it can also mean back-end-as-a-service (BaaS) platforms or even query services that run SQL statements in the cloud, managing any of the required infrastructure and scalability for you.

One of the most exciting promises of serverless computing, whether FaaS, BaaS, or a SQL query service, is that it enables you to focus solely on providing business value to your organizations. Developers who want to decrease management of infrastructure, increase time to market, and improve scalability of their apps seek out a serverless approach.

You can run SQL statements against your Cloud Object Storage data in a serverless fashion with SQL Query, one of the Analytics services available on IBM Cloud. You don’t have to worry about sizing servers. You can just write your statements and submit them to be run on the cloud.

The serverless nature of SQL Query makes it a great match for IBM Cloud Functions, which are based on OpenWhisk. By making your SQL Query calls from within IBM Cloud Functions, you can add your own custom code for data processing or add your own security for limiting the types or number of queries that are allowed against your object store.

In the IBM-Cloud organization on GitHub at /IBM-Cloud/openwhisk-sql-query/, you can find a package with a few example actions for IBM Cloud Functions that interact with the SQL Query service. Follow the instructions for deploying the openwhisk-sql-query package into your own namespace. After you deploy the package, you have some actions and sequences in your namespace. These functions submit SQL statements, get information on previously run sql jobs, and get your results back from Cloud Object Storage. Because you deployed this package into your own namespace, you can edit and update the code to suit your own project. You can build and change the package to make it your own, depending on what you’re trying to achieve.

Check out the video at the top of the post to see this package in action. To see a more complex use case of obtaining and visualizing cloud usage and billing data, check out the sample code at /IBM-Cloud/openwhisk-cloud-usage-sample/.

Try out the sample code to work with SQL Query, Cloud Object Storage, and Cloud Functions, and feel free to reach out with any questions or ideas you have for new features and packages!