diff --git a/tap_redshift/__init__.py b/tap_redshift/__init__.py index 90b634e..c172505 100644 --- a/tap_redshift/__init__.py +++ b/tap_redshift/__init__.py @@ -142,7 +142,8 @@ def discover_catalog(conn, db_schema): stream=table_name, schema=schema, table=qualified_table_name, - metadata=metadata) + metadata=metadata, + database=db_name) entries.append(entry) @@ -251,7 +252,7 @@ def open_connection(config): dbname = config['dbname'], user = config['user'], password = config['password'] - + LOGGER.info(f"Attempting Redshift connection: {dbname[0]} {host[0]} {port[0]}") connection = psycopg2.connect( host=host[0], port=port[0], @@ -304,8 +305,10 @@ def sync_table(connection, catalog_entry, state): LOGGER.info('Beginning sync for {} table'.format(tap_stream_id)) with connection.cursor() as cursor: schema, table = catalog_entry.table.split('.') - select = 'SELECT {} FROM {}.{}'.format( + database = catalog_entry.database + select = 'SELECT {} FROM {}.{}.{}'.format( ','.join('"{}"'.format(c) for c in columns), + '"{}"'.format(database), '"{}"'.format(schema), '"{}"'.format(table)) params = {} diff --git a/tap_redshift/resolve.py b/tap_redshift/resolve.py index 3f38442..fe6a9a1 100644 --- a/tap_redshift/resolve.py +++ b/tap_redshift/resolve.py @@ -120,7 +120,8 @@ def resolve_catalog(discovered, catalog, state): stream=catalog_entry.stream, table=catalog_entry.table, schema=schema, - metadata=catalog_entry.metadata + metadata=catalog_entry.metadata, + database=catalog_entry.database )) return result