Re: MySQL, Django, Python, html allllll in one! Help!!!
Thanks! So , I ended up doing something along those lines and creating an external data source that would upload to a specific url that the google viz html script would import and pull the info from there to make the graph. So hoorah! this is my code:
#######################
#define the function with an http request parameter
def Library(request):
# The table schema is a collection of column descriptors. These are also the columns from the MySQl table PracticeData
description = {('ID' , 'number') : [('DateAndTime', 'string'),('TemperatureF', 'number')]} #This is the table schema
dictionary=PracticeData.objects.all().values()#This line calls all of the objects in the MySQL table using Django framework.
NewDictionary={} #create a new dictionary to put the actual data in
#note that the format of the data has to match the format of the schema. In this case, a dictionary with many keys, each assigned to two values
#This for loop creates the keys based on a number and assigns two values to each key which are DateAndTime and TempF each taken from the variable dictionary
#DataAndTime is converted to a string instead of datetime.... graph can read it then as x-axis
for i in range(len(dictionary)):
NewDictionary.setdefault((i),[str(dictionary["DateAndTime"]), (dictionary["TemperatureF"])])
data = NewDictionary
data_table = gviz_api.DataTable(description)
data_table.LoadData(data)
print "Content-type: text/plain"
print
return HttpResponse(data_table.ToJSonResponse(columns_order=('DateAndTime','TemperatureF'), order_by= 'ID'))
So my next question for pondering.... now that I can put the interactive google graphs on a webpage, how do I put in a search bar there that would enable the user to then query the mysql db and tell my datasource which info to display?
Subject
Written By
Posted
Re: MySQL, Django, Python, html allllll in one! Help!!!
August 09, 2010 10:55AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.