Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import sqlite3 conn = sqlite3.connect("demo.db") cursor = conn.cursor() cursor.execute( ''' CREATE TABLE IF NOT EXISTS studenttb(id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,age INTEGER) ''' ) conn.commit() def insert(): name = input("Enter the name : ") age = int(input("Enter the age : ")) cursor.execute('''INSERT INTO studenttb(name,age) VALUES (?,?)''',(name,age)) conn.commit() print("Record Inserted") def display(): cursor.execute(''' SELECT * FROM studenttb ''') row = cursor.fetchall() for r in row: print(r) def update(): id = int(input("Enter the id to update : ")) new_age = int(input("Enter the new age : ")) cursor.execute("UPDATE studenttb SET age=? WHERE id=?",(new_age,id)) conn.commit() print("Record Updated") def delete(): id = int(input("Enter the id to delete : ")) cursor.execute("DELETE FROM studenttb WHERE id=?",(id,)) print("Record Deleted") while True: print("1 - Insert") print("2 - Display") print("3 - Update") print("4 - Delete") print("5 - Exit") choice = input("Enter the choice : ") if choice == "1": insert() elif choice == "2": display() elif choice == "3": update() elif choice == "4": delete() elif choice == "5": print("Exit") break else: print("Wrong choice") conn.close()
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)