bug fix: duckdb readonly, version update with edition

v2.4
Steve Nyemba 1 month ago
parent a6da232d5f
commit 97c5ae6fb3

@ -1,6 +1,7 @@
__app_name__ = 'data-transport'
__author__ = 'The Phi Technology'
__version__= '2.4.16'
__edition__= 'ent'
__email__ = "info@the-phi.com"
__license__=f"""
Copyright 2010 - 2024, Steve L. Nyemba

@ -5,14 +5,14 @@ from setuptools import setup, find_packages
import os
import sys
# from version import __version__,__author__
from info import __version__, __author__,__app_name__,__license__
from info import __version__, __author__,__app_name__,__license__,__edition___
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {
"name":__app_name__,
"version":__version__,
"version":'-'.join([__version__,__edition__]),
"author":__author__,"author_email":"info@the-phi.com",
"license":__license__,
# "packages":["transport","info","transport/sql"]},

@ -13,7 +13,13 @@ class Base:
self._port = None
self._database = _args['database']
self._table = _args['table'] if 'table' in _args else None
self._engine= sqa.create_engine(self._get_uri(**_args),future=True)
_uri = self._get_uri(**_args)
if type(_uri) == str :
self._engine= sqa.create_engine(_uri,future=True)
else:
_uri,_kwargs = _uri
self._engine= sqa.create_engine(_uri,**_kwargs,future=True)
def _set_uri(self,**_args) :
"""
:provider provider
@ -64,8 +70,8 @@ class Base:
@TODO: Execution of stored procedures
"""
if sql.strip().lower().startswith('select') or sql.strip().lower().startswith('with') :
if sql.strip().lower().startswith('select') or sql.strip().lower().startswith('with') or sql.strip().startswith('show'):
print (self._engine)
return pd.read_sql(sql,self._engine)
else:
_handler = self._engine.connect()
@ -146,4 +152,4 @@ class BaseWriter (SQLBase):
# if 'if_exists' in _args :
# _mode['if_exists'] = _args['if_exists']
_df.to_sql(_table,self._engine,**_mode)
_df.to_sql(_table,self._engine,**_mode)

@ -2,9 +2,8 @@
This module implements the handler for duckdb (in memory or not)
"""
from transport.sql.common import Base, BaseReader, BaseWriter
from multiprocessing import RLock
class Duck :
lock = RLock()
def __init__(self,**_args):
#
# duckdb with none as database will operate as an in-memory database
@ -16,11 +15,12 @@ class Duck :
def _get_uri(self,**_args):
return f"""duckdb:///{self.database}"""
class Reader(Duck,BaseReader) :
def __init__(self,**_args):
def __init__(self,**_args):
Duck.__init__(self,**_args)
BaseReader.__init__(self,**_args)
def _get_uri(self,**_args):
return super()._get_uri(**_args),{'connect_args':{'read_only':True}}
class Writer(Duck,BaseWriter):
def __init__(self,**_args):
Duck.__init__(self,**_args)
BaseWriter.__init__(self,**_args)
Loading…
Cancel
Save