Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
How can I put data from mySQL in a Google chart?

I have tried for several days to get MySQL data in a Google chart but I can't seem to work out how to make a working page from the examples I've come across on the internet.

I've created some dummy data which randomly creates data in an SQLite-3.py file:

import sqlite3
import time
import datetime
import random

conn = sqlite3.connect('tutorial.db')
c = conn.cursor()

def create_table():
    c.execute('CREATE TABLE IF NOT EXISTS stuffToPlot(unix REAL, datestamp TEXT, keyword TEXT, value REAL)')

def dynamic_data_entry():
    unix = time.time()
    date = (datetime.datetime.fromtimestamp(unix).strftime('%Y-%M-%D %H: %M: %S'))
    keyword = 'Python'
    value = random.randrange(0, 10)
    c.execute("INSERT INTO stuffToPlot VALUES (?, ?, ?, ?)", (unix, date, keyword, value))
    conn.commit()

def read_from_db():
    c.execute('SELECT * FROM stuffToPlot') # * betekend dat je alles selecteert van ....
    # data = c.fetchall()
    # print(data)
    for row in c.fetchall():
        print(row)

This creates a datatable shown here in the SQLite explorer: datatable

I have also put in a Google cart which is shown on a webpage, created in graph.html, which right now has static data, but I want to put in the variable data from the database:

  var data = new google.visualization.DataTable();
    data.addColumn('string', 'Task')
    data.addColumn('number', 'Hours per Day')
    data.addRows([
    ['Work', 11],
    ['Eat', 2],
    ['Commute', 2],
    ['Watch TV', 2],
    ['Sleep', {v:7, f:'7.000'}]
    ]);

It is unclear to me how I can connect the database to the chart to make a working graph with the variable data.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try these links

https://developers.google.com/chart/interactive/docs/php_example

Display a google chart with json & PHP

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!