mardi 17 février 2015

SQLite database in python oop

I tried to build SQLite database useing python OOP. then i program it as below and It's working fine. so I want to know, Did i duly follow OOP concepts in this program ?



import sqlite3

class connect(object):

def __init__(self):

self.Database = sqlite3.connect("test4.sqlite")
self.cour = self.Database.cursor()

def quary (self,qury):

try:
self.cour.execute(qury)
self.cour.close()
print (" Database Creted")

except:

print("some error in Sqlite query")


obj = connect()
q = obj.quary("""CREATE TABLE users(id INTEGER PRIMARY KEY,
name TEXT,
phone TEXT,
email TEXT unique,
password TEXT) """)

Aucun commentaire:

Enregistrer un commentaire