-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'OracleDialect_cx_oracle' object has no attribute 'default_schema_name' #29
Comments
Hi @hanknac |
@hanknac same problem here. Were you able to solve the problem? @mohaseeb I'm using Python 2 and mssql dialect (driver pyodbc). On relational_db_api.load_table() you try to check if the table exists "engine.dialect.has_table(engine, name)", but inside this SqlAchemy method the property default_schema_name of dialect is used, but in this moment, the property does not exist. To "resolve quickly" I did the following: in the relational_db file, inside class "_ReadFromRelationalDBFn" I added this line after db.start_session():
|
I'm facing the same problem as @ferreira-guilherme, but in my use case, i'm using a SQLServer Dialect: from future import print_function def run(argv=None, save_main_session=True): if name == 'main': Result: File "/home/rodrigo/projects/liq/workspace/dataflow/template_teste/lib/python3.6/site-packages/beam_nuggets/io/relational_db_api.py", line 325, in _get_table I've tried your solution @ferreira-guilherme and worked for me. Thanks! |
I am trying to use beam-nuggets to access Oracle, and I am receiving:
AttributeError: 'OracleDialect_cx_oracle' object has no attribute 'default_schema_name'
Code:
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
from beam_nuggets.io import relational_db
with beam.Pipeline(options=PipelineOptions()) as p:
source_config = relational_db.SourceConfiguration(
drivername='oracle+cx_oracle',
host='...',
port=1521,
username='',
password=''
)
records = p | "Reading records from db" >> relational_db.ReadFromDB(
source_config=source_config,
table_name = 'CONTACTS',
query='select * from EHR.CONTACTS' # optional. When omitted, all table records are returned.
)
records | 'Writing to stdout' >> beam.Map(print)
Stack trace:
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db.py in process(self, element)
94 try:
95 if query:
---> 96 for record in db.query(table_name, query):
97 yield record
98 else:
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db_api.py in query(self, table_name, query)
267
268 def query(self, table_name, query):
--> 269 table = self._open_table_for_read(table_name)
270 for record in table.query_records(self._session, query):
271 yield record
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db_api.py in _open_table_for_read(self, name)
302 return self._open_table(
303 name=name,
--> 304 get_table_f=load_table
305 )
306
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db_api.py in _open_table(self, name, get_table_f, **get_table_f_params)
317 if not table:
318 self._name_to_table[name] = (
--> 319 self._get_table(name, get_table_f, **get_table_f_params)
320 )
321 table = self._name_to_table[name]
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db_api.py in _get_table(self, name, get_table_f, **get_table_f_params)
323
324 def _get_table(self, name, get_table_f, **get_table_f_params):
--> 325 table_class = get_table_f(self._session, name, **get_table_f_params)
326 if table_class:
327 table = _Table(table_class=table_class, name=name)
/opt/conda/lib/python3.7/site-packages/beam_nuggets/io/relational_db_api.py in load_table(session, name)
378 table_class = None
379 engine = session.bind
--> 380 if engine.dialect.has_table(engine, name):
381 metadata = MetaData(bind=engine)
382 table_class = create_table_class(Table(name, metadata, autoload=True))
/opt/conda/lib/python3.7/site-packages/sqlalchemy/dialects/oracle/base.py in has_table(self, connection, table_name, schema)
1356 def has_table(self, connection, table_name, schema=None):
1357 if not schema:
-> 1358 schema = self.default_schema_name
1359 cursor = connection.execute(
1360 sql.text(
AttributeError: 'OracleDialect_cx_oracle' object has no attribute 'default_schema_name'
The text was updated successfully, but these errors were encountered: