From c443c6c953b1bf2ca7eae4cbcce6dde0e095c403 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Sat, 15 Jun 2024 00:50:53 -0500 Subject: [PATCH] duckdb support --- setup.py | 4 ++-- transport/sql/__init__.py | 2 +- transport/sql/duckdb.py | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 transport/sql/duckdb.py diff --git a/setup.py b/setup.py index 002feb8..9b46d71 100644 --- a/setup.py +++ b/setup.py @@ -18,8 +18,8 @@ args = { # "packages":["transport","info","transport/sql"]}, "packages": find_packages(include=['info','transport', 'transport.*'])} -args["keywords"]=['mongodb','couchdb','rabbitmq','file','read','write','s3','sqlite'] -args["install_requires"] = ['pyncclient','pymongo','sqlalchemy','pandas','typer','pandas-gbq','numpy','cloudant','pika','nzpy','boto3','boto','pyarrow','google-cloud-bigquery','google-cloud-bigquery-storage','flask-session','smart_open','botocore','psycopg2-binary','mysql-connector-python','numpy','pymssql'] +args["keywords"]=['mongodb','duckdb','couchdb','rabbitmq','file','read','write','s3','sqlite'] +args["install_requires"] = ['pyncclient','duckdb-engine','pymongo','sqlalchemy','pandas','typer','pandas-gbq','numpy','cloudant','pika','nzpy','boto3','boto','pyarrow','google-cloud-bigquery','google-cloud-bigquery-storage','flask-session','smart_open','botocore','psycopg2-binary','mysql-connector-python','numpy','pymssql'] args["url"] = "https://healthcareio.the-phi.com/git/code/transport.git" args['scripts'] = ['bin/transport'] # if sys.version_info[0] == 2 : diff --git a/transport/sql/__init__.py b/transport/sql/__init__.py index 9d026bf..b5aaa98 100644 --- a/transport/sql/__init__.py +++ b/transport/sql/__init__.py @@ -3,7 +3,7 @@ This namespace/package wrap the sql functionalities for a certain data-stores - netezza, postgresql, mysql and sqlite - mariadb, redshift (also included) """ -from . import postgresql, mysql, netezza, sqlite, sqlserver +from . import postgresql, mysql, netezza, sqlite, sqlserver, duckdb # diff --git a/transport/sql/duckdb.py b/transport/sql/duckdb.py new file mode 100644 index 0000000..ab82bb2 --- /dev/null +++ b/transport/sql/duckdb.py @@ -0,0 +1,21 @@ +""" +This module implements the handler for duckdb (in memory or not) +""" +from transport.sql.common import Base, BaseReader, BaseWriter + +class Duck : + def __init__(self,**_args): + self.database = _args['database'] + def get_provider(self): + return "duckdb" + + def _get_uri(self,**_args): + return f"""duckdb:///{self.database}""" +class Reader(Duck,BaseReader) : + def __init__(self,**_args): + Duck.__init__(self,**_args) + BaseReader.__init__(self,**_args) +class Writer(Duck,BaseWriter): + def __init__(self,**_args): + Duck.__init__(self,**_args) + BaseWriter.__init__(self,**_args)