bug fix, added ferretdb

This commit is contained in:
Steve Nyemba 2023-05-25 09:39:51 -05:00
parent 64f0b3ca80
commit 695c10e797
5 changed files with 22 additions and 3 deletions

View File

@ -8,7 +8,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {
"name":"data-transport",
"version":"1.6.6",
"version":"1.6.8",
"author":"The Phi Technology LLC","author_email":"info@the-phi.com",
"license":"MIT",
"packages":["transport"]}

View File

@ -55,6 +55,7 @@ import os
class providers :
POSTGRESQL = 'postgresql'
MONGODB = 'mongodb'
BIGQUERY ='bigquery'
FILE = 'file'
ETL = 'etl'
@ -72,8 +73,10 @@ class providers :
# synonyms of the above
BQ = BIGQUERY
MONGO = MONGODB
FERRETDB= MONGODB
PG = POSTGRESQL
PSQL = POSTGRESQL
PGSQL = POSTGRESQL
class IEncoder (json.JSONEncoder):
def default (self,object):

View File

@ -22,6 +22,7 @@ import numpy as np
import json
import importlib
from multiprocessing import RLock
import queue
# import couch
# import mongo
@ -115,6 +116,8 @@ class Console(Writer):
finally:
if self.lock :
Console.lock.release()
"""
@NOTE : Experimental !!
"""

View File

@ -124,7 +124,15 @@ class MongoReader(Mongo,Reader):
return pd.DataFrame(r)
else:
collection = self.db[self.uid]
if 'table' in args or 'collection' in args :
if 'table' in args:
_uid = args['table']
elif 'collection' in args :
_uid = args['collection']
else:
_uid = self.uid
collection = self.db[_uid]
_filter = args['filter'] if 'filter' in args else {}
_df = pd.DataFrame(collection.find(_filter))
columns = _df.columns.tolist()[1:]
@ -185,6 +193,9 @@ class MongoWriter(Mongo,Writer):
# self.db[self.uid].insert_many(info)
# else:
try:
if 'table' in _args or 'collection' in _args :
_uid = _args['table'] if 'table' in _args else _args['collection']
else:
_uid = self.uid if 'doc' not in _args else _args['doc']
if self._lock :
Mongo.lock.acquire()

View File

@ -278,7 +278,9 @@ class SQLWriter(SQLRW,Writer):
try:
table = _args['table'] if 'table' in _args else self.table
self.schema = _args['schema'] if 'schema' in _args else self.schema
table = self._tablename(table)
_sql = "INSERT INTO :table (:fields) VALUES (:values)".replace(":table",table) #.replace(":table",self.table).replace(":fields",_fields)
if type(info) == list :