lunedì 2 gennaio 2012

Semplice esempio di SqlLite con Python per Android


nessuna pretesa...giusto una snippet
---------------------------------------------------------------------------
import sqlite3
import android


nome = ""
droid=android.Android()
# Connect to database file, create it if it does not exist
conn = sqlite3.connect('/sdcard/sqlitedemo.db')




# Get a cursor
cursor = conn.cursor()




# Create a table
cursor.execute("CREATE TABLE IF NOT EXISTS anagrafica (nome text)")




# Insert some data
while nome<>"exit":
     nome=droid.dialogGetInput("","Il nome prego").result
     sql_string = "INSERT INTO anagrafica VALUES ('"+str(nome)+"')"
     print sql_string
     cursor.execute(sql_string)
     conn.commit()




# Read the data back out
cursor.execute("SELECT * from anagrafica")
for row in cursor:
     print row

Nessun commento:

Posta un commento

FigSpec FS-60CL

A lavoro mi hanno rifilato questo sensore iperspettrale cinese (pushbroom 400-1000 nm con larghezza di banda di 0.5 nm compatibile con DJI M...