Created
July 19, 2021 10:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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