defron / ISSAMemberManager

Mozilla Public License 2.0
2 stars 14 forks source link

Create Database Connector Class #11

Open defron opened 9 years ago

defron commented 9 years ago

database connector object needs to be created @octaviolmos

octaviolmos commented 9 years ago

!/usr/bin/python

import sqlite3

conn = sqlite3.connect('memberdb.db') c = conn.cursor()

print "Opened database successfully";

cursor = conn.execute("SELECT ID, FirstName, LastName, Email, Phone, GradYear from PEOPLE") for row in cursor: print "ID = ", row[0] print "FIRSTNAME = ", row[1] print "LASTNAME = ", row[2] print "EMAIL = ", row[3] print "PHONE = ", row[4] print "GRADYEAR = ", row[5], "\n"

print "Displaying People table done successfully"; conn.close()

defron commented 9 years ago

Hi @octaviolmos . We need to do everything in an object-oriented manner, so can you convert this to a class? Also remove all the print lines, as UI aspects need to be separated from the functional aspects of the program. Instead just return the data.

A database class with methods for opening the db, executing a sql statement, and closing the connection would be good places to start I think.

defron commented 9 years ago

Look into using **kwargs for handling dynamic record updates and using a variable for determining table.

Make sure to use named parameters for updated data.

@vcao2279 @octaviolmos