Merge pull request 'fixes 2024 pandas-gbq and sqlalchemy' (#10) from dev into master

Reviewed-on: #10
master
Steve L. Nyemba 9 months ago
commit 68b8f6af5f

@ -1,5 +1,5 @@
__author__ = 'The Phi Technology' __author__ = 'The Phi Technology'
__version__= '1.9.8' __version__= '1.9.8.1'
__license__=""" __license__="""

@ -20,26 +20,10 @@ args = {
"license":"MIT", "license":"MIT",
"packages":["transport","info"]} "packages":["transport","info"]}
args["keywords"]=['mongodb','couchdb','rabbitmq','file','read','write','s3','sqlite'] args["keywords"]=['mongodb','couchdb','rabbitmq','file','read','write','s3','sqlite']
args["install_requires"] = ['pyncclient','pymongo','sqlalchemy<2.0.0','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'] 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']
args["url"] = "https://healthcareio.the-phi.com/git/code/transport.git" args["url"] = "https://healthcareio.the-phi.com/git/code/transport.git"
args['scripts'] = ['bin/transport'] args['scripts'] = ['bin/transport']
if sys.version_info[0] == 2 : if sys.version_info[0] == 2 :
args['use_2to3'] = True args['use_2to3'] = True
args['use_2to3_exclude_fixers']=['lib2to3.fixes.fix_import'] args['use_2to3_exclude_fixers']=['lib2to3.fixes.fix_import']
setup(**args) setup(**args)
# setup(
# name = "data-transport",
# version = "1.0",
# author = "The Phi Technology LLC",
# author_email = "steve@the-phi.com",
# license = "MIT",
# packages=['transport'],
# keywords=['mongodb','couchdb','rabbitmq','file','read','write','s3'],
# install_requires = ['pymongo','numpy','cloudant','pika','boto','flask-session','smart_open'],
# url="https://dev.the-phi.com/git/steve/data-transport.git",
# use_2to3=True,
# long_description=read('README.md'),
# convert_2to3_doctests=['README.md'],
# #use_2to3_fixers=['your.fixers'],
# use_2to3_exclude_fixers=['lib2to3.fixes.fix_import'],
# )

@ -29,6 +29,7 @@ from google.cloud import bigquery as bq
from multiprocessing import Lock, RLock from multiprocessing import Lock, RLock
import pandas as pd import pandas as pd
import pandas_gbq as pd_gbq
import numpy as np import numpy as np
import nzpy as nz #--- netezza drivers import nzpy as nz #--- netezza drivers
import sqlite3 import sqlite3
@ -409,7 +410,7 @@ class BigQuery:
_dataset = self.dataset if 'dataset' not in _args else _args['dataset'] _dataset = self.dataset if 'dataset' not in _args else _args['dataset']
sql = f"""SELECT column_name as name, data_type as type FROM {_dataset}.INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{table}' """ sql = f"""SELECT column_name as name, data_type as type FROM {_dataset}.INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{table}' """
_info = {'credentials':self.credentials,'dialect':'standard'} _info = {'credentials':self.credentials,'dialect':'standard'}
return pd.read_gbq(sql,**_info).to_dict(orient='records') return pd_gbq.read_gbq(sql,**_info).to_dict(orient='records')
# return self.read(sql=sql).to_dict(orient='records') # return self.read(sql=sql).to_dict(orient='records')
# ref = self.client.dataset(self.dataset).table(table) # ref = self.client.dataset(self.dataset).table(table)
@ -451,7 +452,7 @@ class BQReader(BigQuery,Reader) :
if (':dataset' in SQL or ':DATASET' in SQL) and self.dataset: if (':dataset' in SQL or ':DATASET' in SQL) and self.dataset:
SQL = SQL.replace(':dataset',self.dataset).replace(':DATASET',self.dataset) SQL = SQL.replace(':dataset',self.dataset).replace(':DATASET',self.dataset)
_info = {'credentials':self.credentials,'dialect':'standard'} _info = {'credentials':self.credentials,'dialect':'standard'}
return pd.read_gbq(SQL,**_info) if SQL else None return pd_gbq.read_gbq(SQL,**_info) if SQL else None
# return self.client.query(SQL).to_dataframe() if SQL else None # return self.client.query(SQL).to_dataframe() if SQL else None

Loading…
Cancel
Save