How do I just display what's in my database in plain HTML or PHP without any GUI interface or layout, just plain database display? Is it possible?

This is my Python code:

import sqlite3
import RPi.GPIO as GPIO
import time
import datetime

GPIO.setup(7, GPIO.OUT)

now = datetime.datetime.now()
timestamp = now.strftime("%Y/%m/%d %H:%M")

pin7 = "INSERT INTO led values('" + "1" + "','" + "Red LED" + "','" + timestamp + "')"

def Blink(numTimes, speed):
    conn = sqlite3.connect(dbname)
    curs = conn.cursor()

    for i in range(numTimes):
        print "Iteration " + str(i + 1)
        GPIO.output(7, True)
        GPIO.output(7, False)
    print "Done"


print "Blinking LED"

iterations = raw_input("Enter total number of times to blink: ")
speed = raw_input("Enter length of each blink(seconds): ")

Blink(int(iterations), float(speed))
  • 1
    You need to get the data out of an sqlite database using Python right? Why are you pasting the database insertion code then? It has nothing to do with your question. Commented Jul 2, 2014 at 10:59
  • Just want to show my code and maybe there are some area I should change so that's why I seeking for help from you guys, Hal Commented Jul 2, 2014 at 11:53
  • @user3127380 This would fit better on Code Review, a site meant for code review or Stack Overflow, a programming-specific Stack Exchange. This site is specifically meant for Raspberry Pi-related issues (GPIO, PiCam, issues that occur only on the Pi - not on a PC, etc...) Commented Jul 4, 2014 at 14:51

1 Answer 1


Here's a sample script to read an sqlite3 database using Python:

import sqlite3 conn = sqlite3.connect('example.db')

c = conn.cursor()

for row in c.execute('SELECT * FROM led'): print row

Check out the documentation, it's pretty good.


Not the answer you're looking for? Browse other questions tagged or ask your own question.