| 
					
				 | 
			
			
				@@ -5,8 +5,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     name:db.py 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     author:rabin 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-from influxdb import InfluxDBClient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import psycopg2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class Influxdb(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	instance = None 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,6 +14,8 @@ class Influxdb(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return Influxdb.instance 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	def __init__(self, config): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		influxdb = __import__('influxdb') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		InfluxDBClient = getattr(influxdb, 'InfluxDBClient') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		self.connect = InfluxDBClient(config['host'], config['port'], config['username'], config['password'], config['dbname']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		self.create(config['dbname']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -35,6 +35,7 @@ class Postgresql(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return Postgresql.instance 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	def __init__(self, config): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		psycopg2 = __import__('psycopg2') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		self.connect = psycopg2.connect(host=config['host'], port=config['port'], user=config['username'], password=config['password'], database=config['dbname']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	def get(self): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -43,4 +44,22 @@ class Postgresql(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	def create(self, name): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		'psql -U postgres' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		sql = 'CREATE DATABASE '+name+' WITH OWNER = postgres ENCODING = "UTF8"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return sql 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class Mysql(object): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	instance = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	def __new__(cls, *args, **kwd): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if Mysql.instance is None: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Mysql.instance = object.__new__(cls, *args, **kwd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return Mysql.instance 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	def __init__(self, config): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		pymysql = __import__('pymysql') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		self.connect = pymysql.connect(host=config['host'], port=config['port'], user=config['username'], password=config['password'], database=config['dbname']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	def get(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return self.connect 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	def create(self, name): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		sql = 'CREATE DATABASE '+name+' ENCODING = "UTF8"' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return sql 
			 |