# Path: src/bin/tools.py
# def GetTimestamp(fractional=False):
# 	'''
# 	 @brief Get string timestamp
# 
# 	 @param fractional (return timestamp with fractional seconds (default=False))
# 
# 	 @return string timestamp 
# 	'''
# 	str_time = "%Y_%m_%d__%H_%M_%S"
# 	if fractional:
# 		timestamp = datetime.utcnow().strftime(str_time + ".%f")
# 	else:
# 		timestamp = datetime.utcnow().strftime(str_time)
# 	return timestamp


import time, json
import numpy as np
from datetime import datetime
from src.bin.tools import GetTimestamp
from MySQL.MySQL import MySQL
from GPS.GPS import GPS
from LogTool.LogTool import LogTool
from FrameRecorder.FrameRecorder import FrameRecorder
		 @return table_name
		'''
		return self.__table_name

	def CreateNewTable(self, dict_list):
		'''
		 @brief Create new table in database with correct columns and values

		 @param dict_list (list of data dictionaries to store in database)
		'''
		columns = {self.__primary_key[0]: self.__primary_key[1]}
		for data_dict in dict_list:
			for key in data_dict:
				columns[key] = self.FindSQLValueType(data_dict[key])
		if not(self.CheckSQLTableExist(self.__table_name)):
			self.CreateSQLTable(self.__table_name, columns, self.__primary_key[0])
		else:
			for key in columns:
				if not(self.CheckSQLColumnExist(self.__table_name, key)):
					self.AddColumnToSQLTable(self.__table_name, (key, columns[key]))
		self.__table_created = True

	def InsertToDatabase(self, dict_list):
		'''
		 @brief Insert data to database.

		 @param dict_list (list of data dictionaries to store in database)
		'''
		if not(self.__table_created):
			self.CreateNewTable(dict_list)

# Path: src/bin/tools.py
# def GetTimestamp(fractional=False):
# 	'''
# 	 @brief Get string timestamp
# 
# 	 @param fractional (return timestamp with fractional seconds (default=False))
# 
# 	 @return string timestamp 
# 	'''
# 	str_time = "%Y_%m_%d__%H_%M_%S"
# 	if fractional:
# 		timestamp = datetime.utcnow().strftime(str_time + ".%f")
# 	else:
# 		timestamp = datetime.utcnow().strftime(str_time)
# 	return timestamp


# Path: src/DataBase/DataBase.py
import time, json
import numpy as np
from datetime import datetime
from src.bin.tools import GetTimestamp
from MySQL.MySQL import MySQL
from GPS.GPS import GPS
from LogTool.LogTool import LogTool
from FrameRecorder.FrameRecorder import FrameRecorder

		 @return table_name
		'''
		return self.__table_name

	def CreateNewTable(self, dict_list):
		'''
		 @brief Create new table in database with correct columns and values

		 @param dict_list (list of data dictionaries to store in database)
		'''
		columns = {self.__primary_key[0]: self.__primary_key[1]}
		for data_dict in dict_list:
			for key in data_dict:
				columns[key] = self.FindSQLValueType(data_dict[key])
		if not(self.CheckSQLTableExist(self.__table_name)):
			self.CreateSQLTable(self.__table_name, columns, self.__primary_key[0])
		else:
			for key in columns:
				if not(self.CheckSQLColumnExist(self.__table_name, key)):
					self.AddColumnToSQLTable(self.__table_name, (key, columns[key]))
		self.__table_created = True

	def InsertToDatabase(self, dict_list):
		'''
		 @brief Insert data to database.

		 @param dict_list (list of data dictionaries to store in database)
		'''
		if not(self.__table_created):
			self.CreateNewTable(dict_list)

		unix_time 	= GetTimestamp(fractional=True)