1. Shu Zong Chen
  2. thumbtack-db

Commits

Shu Zong Chen  committed dee4cbc

GET/SET done yo

  • Participants
  • Parent commits e8209cd
  • Branches default

Comments (0)

Files changed (2)

File simpledb/__init__.py

View file
 		if hasattr(self.db, 'DO_' + cmd):
 			f = getattr(self.db, 'DO_' + cmd)
 			try:
-				f(*args)
+				v = f(*args)
+				if v:
+					print v
 			except TypeError:
 				print "INCORRECT NUM OF ARGS FOR CMD: {0}".format(cmd)

File simpledb/engine.py

View file
 		self.c = Counter()
 
 	def DO_SET(self, name, value):
-		pass
+		if name in self.d:
+			self.c[self.d[name]] -= 1
+		self.c[value] += 1
+		self.d[name] = value
 
 	def DO_GET(self, name):
-		pass
+		try:
+			return self.d[name]
+		except KeyError:
+			return 'NULL'
 
 	def DO_UNSET(self, name):
-		pass
+		if name in self.d:
+			self.c[self.d[name]] -= 1
+		del self.d[name]
 
 	def DO_NUMEQUALTO(self, name):
 		pass
 
-	def DO_END(self, name):
+	def DO_END(self):
 		raise StopProgram