Ejemplo 1: ¿está instalado sqlite como parte de python3?
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
# Save (commit) the changes
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
Ejemplo 2: instalar sqlite3 python
pip install pysqlite3
Ejemplo 3: cómo instalar sqlite3 en python
pip install sqlite
Ejemplo 4: cómo instalar sqlite3 en python
if you are using python3, sqlite3 is built in into it.
Ejemplo 5: cómo instalar sqlite3 python
pip install db-sqlite3
Ejemplo 6: python sqlite3
import sqlite3 as lite
import sys
try:
con = lite.connect('products.db')
cur = con.cursor()
cur.execute("CREATE TABLE drinks(Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Price REAL)")
cur.execute("CREATE TABLE fruits(Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Price REAL)")
con.commit()
except e:
if con:
con.rollback()
print("Unexpected error %s:" % e.args[0])
sys.exit(1)
finally:
if con:
con.close()
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)