Created
November 13, 2020 09:17
-
-
Save blacksmithop/95f7d7410b3e4f7a0b43d56703279cfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from pprint import pprint | |
class DB: | |
def __init__(self): | |
self.con = sqlite3.connect('newdb.db') | |
self.cur = self.con.cursor() | |
def view_table(self): | |
self.cur.execute("Select * from NEW") | |
pprint(self.cur.fetchall()) | |
def delete(self): | |
id = int(input("ID to Delete: ")) | |
self.cur.execute(f"DELETE FROM NEW where id=={id};") | |
self.view_table() | |
self.con.commit() | |
def __del__(self): | |
self.con.close() | |
if __name__ == "__main__": | |
db = DB() | |
db.view_table() | |
db.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment