I want to convert the SQL query result as json using SQL statement with Python. This is the SQL command I am trying
select *
from mydb
for json auto
I also tried for json path
.
And I also tried with without_array_wrapper
but its returning only one row from the list.
If I run the query without for json auto|path
, it's returning 8 rows, but when I run it with for json auto|path
, I only get 4 rows (instead of 8), and its converting the 8 rows into 4 and returns an array of 4.
This is my Python code
cursor.execute(query)
result = cursor.fetchall()
Can somebody please help me figure out and fix this issue?