# pip install mysql-connector-python
import sqlite3
conn = sqlite3.connect("student.db")
cur=conn.cursor()
cur.execute(
"""
CREATE TABLE IF NOT EXISTS students(
id INTEGER PRIMARY KEY,
name TEXT,
age INTEGER
)
"""
)
# cur.execute("INSERT INTO students(name, age) VALUES(?, ?)",("Gunjan", 21))
cur.execute("INSERT INTO students(name,age) values ('Gunjan',20)")
conn.commit()
cur.execute("SELECT * FROM students where age=20")
rows=cur.fetchall()
for r in rows:
print(r)
# conn.commit()
Comments
Post a Comment