Jan W
04/13/2023, 4:57 PMconst HOST = "<http://localhost:9000>"
async function run() {
try {
const query = "SELECT el_wiatrowe, timestamp FROM 'pse_grid' WHERE timestamp BETWEEN '2023-01-01 00:00:00' AND '2023-04-13 00:00:00' LIMIT 1000000;"
const response = await fetch(`${HOST}/exec?query=${encodeURIComponent(query)}`, {mode:"no-cors"})
const json = await response.text()
console.log(json)
} catch (error) {
console.log(error)
}
}
however when I do the same query in python it's fine:
sql_query = f"SELECT {str(data_string)}, timestamp FROM 'pse_grid' WHERE timestamp BETWEEN '{start_questdb_timestamp}' AND '{end_questdb_timestamp}' LIMIT {limit};"
############################# REQUEST
response = requests.get(
database+'/exec', #exp for csv
params={'query': sql_query,}).json()
thanks for your help!const fetch = require("node-fetch")
instead of this:
<script src="<https://unpkg.com/node-fetch>"></script>
Alex Pelagenko
04/13/2023, 5:43 PMJan W
04/13/2023, 5:56 PMAlex Pelagenko
04/13/2023, 6:19 PMJan W
04/13/2023, 8:14 PM