Forums

Create a JSON feed

Hi - Thanks for taking the time to read this!

I have a python script that is populating several tables in my database. this is all working great, BUT, i'd like to make this data available for another website

I figure the best way to to create a JSON feed, but I'm a bit lost.

Put simply. how do turn "select * from mytable" into a JSON feed i can use to pull into a php file elsewhere

THANK YOU!

This is more a general coding question than a PythonAnywhere-specific one, so you might get better responses on a general programming Q&A site like Stack Overflow, but in general I'd recommend just putting the output of your query into a data structure made up of only lists, dictionaries, strings, booleans and numbers, then using Python's build-in json library to serialize that to JSON -- check out the dumps function -- and return that from a view.