コード例 #1
0
	def _save_to_disk(self, clients):
		tmp_table_name = self.table_name+'.tmp'
		with open(tmp_table_name, mode='w') as f:
			writer = csv.DictWriter(f, fieldnames=ClientModel.shema()) 
			writer.writerows(clients)

			os.remove(self.table_name)
			os.rename(tmp_table_name, self.table_name)
コード例 #2
0
	def list_clients(self):
		with open(self.table_name, mode='r') as f:
			reader = csv.DictReader(f, fieldnames=ClientModel.shema())

			return list(reader)
コード例 #3
0
	def create_client(self, client):
		with open(self.table_name, mode='a') as f:
			writer = csv.DictWriter(f, fieldnames=ClientModel.shema()) 
			writer.writerow(client.to_dic())