Skip to content

Instantly share code, notes, and snippets.

@blacksmithop
Created November 13, 2020 09:17
Show Gist options
  • Save blacksmithop/95f7d7410b3e4f7a0b43d56703279cfc to your computer and use it in GitHub Desktop.
Save blacksmithop/95f7d7410b3e4f7a0b43d56703279cfc to your computer and use it in GitHub Desktop.
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