Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- dbname = "WEB02"
- username = "postgres"
- pwname = ""
- class DB:
- def __init__(self):
- self.condb()
- def __del__(self):
- self.clodb()
- def condb(self):
- self.connectDB = psycopg2.connect(database=dbname,user=username,password=pwname)
- self.cur = self.connectDB.cursor()
- def selCategories(self):
- self.cur.execute("SELECT * FROM categories")
- return self.cur.fetchall()
- def insCategories(self, value):
- self.cur.execute("INSERT INTO categories (name) VALUES ('"+value+"')")
- def clodb(self):
- self.connectDB.close()
Add Comment
Please, Sign In to add comment