Simple data sharing with Data Clips

What is a Dataclip?

A Dataclip is a secret URL that holds the results of a SQL query on a particular Heroku Postgres database. Given the unique, private URL for a query, a user can call up the most recently stored results of that query. Our system will automatically re-run the Dataclip from time to time in order to keep results fresh. By sharing a Dataclip URL the same way you would share the underlying data, any recipient can view that data within, download it as a CSV, or even embed it live into a tool like Google Sheets.

When we share information on the Internet, we do so by sharing URLs.We send URLs for locations, books, videos, and even source code. Until now there hasn't been a convenient way to share data inside a database. That's why we're introducing Data Clips. They are a fast and easy way to unlock the data in your database in the form of a secure URL.

Data Clips allow the results of SQL queries on a Heroku Postgres database to be easily shared. Simply create a query on postgres.heroku.com, and then share the resulting URL with co-workers, colleagues, or the world. Data clips can be shared through e-mail, Twitter, irc, or any other medium - they are just URLs. The recipients of a data clip are able to view the data in their browser or download it in JSON, CSV, XML, or Microsoft Excel formats.

Data changes rapidly in databases. We've created Data Clips with this in mind. They can either be locked to a point in time or set to refresh with live data. When locked to a point in time, data clips are guaranteed to show an unchanging snapshot of data, even if they are viewed hours, days, or years after the clip was created. Alternatively, when data clips are set to "Now", they provide a live view into the database.

Details

  • Data Clips are immediately available in beta on all Heroku Postgres dedicated databases.
  • Data Clips utilize the excellent Ace Code Editor for SQL entry.
  • To reduce the risk of altering your data, Data Clips query databases within a read-only transaction.
  • Results are limited to 10,000 rows.
  • To limit the load on your database, Data Clips refresh a maximum of once every 60 seconds.

In Conclusion

Data sitting quietly in a database doesn’t do any good for anyone. That’s why we added Dataclips into every Heroku Postgres database and rebuilt Dataclips based on your feedback to be faster, easier to use, and better integrated with the Heroku dashboard.

Use below code to fetch data from dataclip via HTTP request --------------------------------------------------------------
HttpResponse res = new HttpResponse(); HttpRequest req = new HttpRequest(); Http http = new Http(); // do your initial http call here req.setMethod('GET'); req.setEndpoint('https://dataclips.heroku.com/rlbumgkvjklpskgqmngmlwvxjxjl-DemoDataclip.json'); res = http.send(req); // redirection checking boolean redirect = false; if(res.getStatusCode() >=300 && res.getStatusCode() <= 307 && res.getStatusCode() != 306) { do { redirect = false; // reset the value each time String loc = res.getHeader('Location'); // get location of the redirect if(loc == null) { redirect = false; continue; } req = new HttpRequest(); req.setEndpoint(loc); req.setMethod('GET'); res = http.send(req); if(res.getStatusCode() != 500) { // 500 = fail if(res.getStatusCode() >=300 && res.getStatusCode() <= 307 && res.getStatusCode() != 306) { redirect= true; } // I do special handling here with cookies // if you need to bring a session cookie over to the // redirected page, this is the place to grab that info } } while (redirect && Limits.getCallouts() != Limits.getLimitCallouts()); } //congratulations you're outside of the redirects now //read what you need from the res object system.debug(res.getBody());

Happy Sharing...


Comments

  1. nice job.....great post man....keep it going... ;)

    ReplyDelete

Post a Comment

Popular posts from this blog

Own Default Email Signature in Salesforce

Log In Password-Free with Lightning Login