Browse Source

bug fixes with sqlite and provider

Steve Nyemba 1 year ago
parent
commit
9da2894b07
2 changed files with 11 additions and 7 deletions
  1. 9 6
      transport/disk.py
  2. 2 1
      transport/providers.py

+ 9 - 6
transport/disk.py

@@ -209,17 +209,20 @@ class SQLiteWriter(SQLite,DiskWriter) :
 		"""
 		"""
 		
-		if not self.fields :
-			if type(info) == pd.DataFrame :
-				_columns = list(info.columns) 
-			self.init(list(info.keys()))
+		#if not self.fields :
+		#	#if type(info) == pd.DataFrame :
+		#	#	_columns = list(info.columns) 
+        #   #self.init(list(info.keys()))
 		
 		if type(info) == dict :
 			info = [info]
 		elif type(info) == pd.DataFrame :
 			info = info.fillna('')
 			info = info.to_dict(orient='records')
-		
+        if not self.fields :
+            _rec = info[0]
+            self.init(list(_rec.keys()))
+
 		SQLiteWriter.LOCK.acquire()
 		try:
 			
@@ -238,4 +241,4 @@ class SQLiteWriter(SQLite,DiskWriter) :
 		except Exception as e :
 			print (e)
 			pass
-		SQLiteWriter.LOCK.release()
+		SQLiteWriter.LOCK.release()

+ 2 - 1
transport/providers.py

@@ -72,6 +72,7 @@ WRITE = {'sql':sql.SQLWriter,'nosql':{MONGODB:mongo.MongoWriter,COUCHDB:couch.Co
 PROVIDERS = {
     FILE:{'read':disk.DiskReader,'write':disk.DiskWriter},
     SQLITE:{'read':disk.SQLiteReader,'write':disk.SQLiteWriter,'driver':sqlite3},
+    'sqlite3':{'read':disk.SQLiteReader,'write':disk.SQLiteWriter,'driver':sqlite3},
     
     POSTGRESQL:{'read':sql.SQLReader,'write':sql.SQLWriter,'driver':pg,'default':{'host':'localhost','port':5432}},
     NETEZZA:{'read':sql.SQLReader,'write':sql.SQLWriter,'driver':nz,'default':{'port':5480}},
@@ -98,4 +99,4 @@ DEFAULT = {PG:{'host':'localhost','port':5432},MYSQL:{'host':'localhost','port':
 DEFAULT[MONGODB] = {'port':27017,'host':'localhost'}
 DEFAULT[REDSHIFT] = DEFAULT[PG]
 DEFAULT[MARIADB] = DEFAULT[MYSQL]
-DEFAULT[NETEZZA] = {'port':5480}
+DEFAULT[NETEZZA] = {'port':5480}