I am querying Teradata using pyodbc and flask with the intention of charting the data using d3.
The result set has two columns, one is a decimal and the other an integer. When I pass the results to my html page and log the output I am getting something along these lines:
[(Decimal(& #39;-16.200000000& #39;), 5), (Decimal(& #39;-23.100000000& #39;), 12), (Decimal(& #39;500.300000000& #39;), 5)].
The embedded data type information is making it difficult to do anything with the result set. How can I get output to look like this instead?
[[-16.200000000, 5], [-23.100000000, 12], [500.300000000, 5]]
In other words I just want an array of arrays.
Steps I am following:
- create a connection
- create a cursor
- execute the SQL
- use
fetchall()
to store the rows in a variable - pass the variable to my html page using
render_template
in javascript set variable equal to data passed in
var data={{dataset}}; console.log(data);
I have seen many flask examples where they take the result set and iterate through it to print the lines in the html but I want to use the resulting dataset as an input to my d3 code. Why is it displaying the data type? And why would it not also display the data type of the integer column?
I am guessing the issue is related to the row construct but I have tried creating a list instead and can't get rid of the data type information. I then get all sorts of errors due to the ampersands.