Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda