Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda