In this video, I demonstrated how to create a SQLite database using Python and perform CRUD operations.
Git Repo: https://github.com/hydrogeologist/pyt...
create database and connection
import sqlite3
conn = sqlite3.connect('tutorialcustomer.db')
#create a table
cursor.execute("""CREATE TABLE customers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT
)
"""
)
#create a table
cursor.execute("""CREATE TABLE customers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT
)
"""
)
Select data from a table
cursor.execute("SELECT * from customers")
Select data from a table
cursor.execute("SELECT * from customers where last_name=”Basu")
cursor.execute("SELECT * from customers where email like ('%gmail%')")
#order data
cursor.execute("""
SELECT * from customers where email like ('%gmail%')
ORDER BY first_name desc
""")
conditionals
cursor.execute("""
SELECT * from customers where email like ('%gmail%')
AND id = 5
ORDER BY first_name desc
""")
for row in cursor.fetchall():
#print(row)
print(row[1] +" " + row[2] + " " + row[3])
Update data into a table
cursor.execute("""
UPDATE customers
SET first_name="UpdatedAnkan"
WHERE id=1
"""
)
Delete data from a table
cursor.execute("""
DELETE from customers
WHERE id=10
"""
)
In questa pagina del sito puoi guardare il video online Python SQLite CRUD - Create Table, Insert, Update, Delete, Where Clause, Conditionals, limiting data della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Cloud Security Training & Consulting 05 aprile 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 558 volte e gli è piaciuto 1 spettatori. Buona visione!