Skip to content

Instantly share code, notes, and snippets.

@panda01
Created July 19, 2021 10:59
Show Gist options
  • Save panda01/4009fdd6ba9a6d8c50e4880b42df1c96 to your computer and use it in GitHub Desktop.
Save panda01/4009fdd6ba9a6d8c50e4880b42df1c96 to your computer and use it in GitHub Desktop.
A simple node program to create a bunch of tables inside of a questdb server running locally
const request = require('request');
function makeANewTable(idx, limit) {
const urlEncodedQuery = encodeURIComponent(`CREATE TABLE IF NOT EXISTS trades${idx} (ts TIMESTAMP, date DATE, name STRING, value INT) timestamp(ts);`);
const wholeUrl = 'http://localhost:9000/exec?query=' + urlEncodedQuery;
request.get(wholeUrl)
.on('response', function(response, a, data) {
console.log(response.statusCode);
const shouldMakeAnotherRequest = idx < limit
if(shouldMakeAnotherRequest) {
makeANewTable(idx + 1, limit);
}
})
.on('error', function(response) {
console.log(response);
});
}
makeANewTable(6000, 9000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment