Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB code #67

Open
ras120 opened this issue Aug 22, 2018 · 2 comments
Open

DB code #67

ras120 opened this issue Aug 22, 2018 · 2 comments
Assignees

Comments

@ras120
Copy link
Collaborator

ras120 commented Aug 22, 2018

db.zip

변경/추가 부분

  1. petName

-Register.py

self.petName = None

def insertUserData(self, user_key, serial, email):
self.openDB()
self.curs = self.conn.cursor()

if self.checkRegistedUser(user_key) == True:
	return exception.REGISTERD_USER

try:
	if self.checkRegistedSerial(serial) == False:
		return exception.NO_REGISTERD_SERIAL
		self.curs.execute(insert.userTable(user_key,serial, email, self.petName))
	self.conn.commit()
	self.closeDB()
	return message.SUCESS_IST_USER
except:
	self.closeDB()
	return exception.DONT_REGIST

def getPetName(self, user_key):
self.openDB()
self.curs = self.conn.cursor()

try:
	self.curs.execute(select.petNameByUserKey(user_key))
	rows = self.curs.fetchone()
	result = " ".join(rows)
	print(result)
	self.closeDB()
	self.petName = result
	return result
except:
	self.closeDB()
	return exception.FAIL_TO_SELECT
  1. oldimagelist

-delete.py
def oldimagelistByAddr

-select.py
def oldimagelistByAddr

-Register.py

def checkoldimagelistByAddr(self, addr):
	self.curs = self.conn.cursor()
	try:
		self.curs.execute(select.oldimagelistByAddr(addr))
		rows = self.curs.fetchall()
		if len(rows) > 0:
			return True
		else :
			return False
	except:
		return False

def insertoldimagelist(self, addr, serial):
	self.openDB()
	self.curs = self.conn.cursor()

	if self.checkRegistedSerial(serial) == False:
		return exception.NO_REGISTERD_SERIAL

	try:
		self.curs.execute(insert.oldimagelistTable(addr, serial))
		self.conn.commit()
		self.closeDB()
		return message.SUCESS_IST_OLD_IMAGE
	except:
		self.closeDB()
		return exception.FAIL_TO_IST_OLD_IMAGE

def deleteoldimagelist(self, addr):
	self.openDB()
	self.curs = self.conn.cursor()

	if self.checkoldimagelistByAddr(addr) == False:
		return False
	try:
		self.curs.execute(delete.oldimagelistByAddr(addr))
		self.conn.commit()
		self.closeDB()
		return True
	except:
		return False

def getoldimagelistFromSerial(self, serial):
	self.openDB()
	self.curs = self.conn.cursor()

	if self.checkRegistedSerial(serial) == False:
		return exception.NO_REGISTERD_SERIAL

	try:
		self.curs.execute(select.pathBySerial(serial))
		rows = self.curs.fetchall()
		image_list = []

		for row in rows:
			print(row[0])
			image_list.append(row[0])

		self.closeDB()
		return image_list

	except:
		self.closeDB()
		return exception.SELECT_FROM_CHECKING_SERIAL

3.home system
-select.py
def petCountBySerial(serial):
return "select * from %s where %s.serial = "%s";" %(
util.SERIAL_TABLE_NAME, util.SERIAL_TABLE_NAME, serial)

-update.py
def petCountBySerial(serial):
return "UPDATE %s SET %s WHERE %s.serial = '%s';" %(
util.SERIAL_TABLE_NAME, util.SERIAL_TABLE_NAME, util.SERIAL_TABLE_NAME, serial)

-Register.py

def getPetCountFromSerial(self,serial):
	self.openDB()
	self.curs = self.conn.cursor()
	if self.checkRegistedSerial(serial) == False:
		self.closeDB()
		return exception.NO_REGISTERD_SERIAL
	try:
		#petCNT = self.curs.execute(select.petCountBySerial(serial))
		petCNT = 0
		self.closeDB()
		print("petCount was deleted")
		return petCNT
	except:
		self.closeDB()
		return  -1

def updatePetCount(self, user_key):
	self.openDB()
	self.curs = self.conn.cursor()

	try:
		self.curs.execute(select.userSerialByUserKey(user_key))
		rows = self.curs.fetchall()
		if len(rows) <= 0:
			return False

		serial = rows[0][0]

		if self.checkRegistedSerial(serial=serial) == False:
			return False

		print(update.petCountBySerial(serial=serial))
		self.curs.execute(update.petCountBySerial(serial=serial))
		self.conn.commit()
		self.closeDB()
		return True
	except:
		self.closeDB()
		return False
@ras120 ras120 self-assigned this Sep 9, 2018
@ras120
Copy link
Collaborator Author

ras120 commented Sep 21, 2018

flask.zip

@ras120
Copy link
Collaborator Author

ras120 commented Oct 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant