Loading multiple files from S3 to Redshift, query completing no data in tablesHow to return multiple values from a function?Importing files from different folderHow can I open multiple files using “with open” in Python?How to install packages using pip according to the requirements.txt file from a local directory?How do I write JSON data to a file?Redshift load for snappy compressed fileloading the bulk data from s3 to redshiftUsing multiple manifest files to load to Redshift from S3?Python loads data from Redshift to S3JSON Data loading into Redshift Table
Salesforce bug enabled "Modify All"
VHDL: Why is it hard to desgin a floating point unit in hardware?
AD: Unable to perform remote desktop logon
Why is the Psionic Artificer considered to be better than all other tier 1 classes?
Ways to spot non-sentient, non-conscious, telepathic shapeshifters
(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?
Is there a filesystem that keep track of all version without snapshot?
Why do testers need root cause analysis?
Nunc est bibendum: gerund or gerundive?
Is a world with one country feeding everyone possible?
Shell builtin `printf` line limit?
How do you earn the reader's trust?
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
If change in free energy (G) is positive, how do those reactions still occur?
What was the primary motivation for a historical figure like Xenophon to create an extensive collection of written material?
Is ideal gas incompressible?
If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?
Must every right-inverse of a linear transformation be a linear transformation?
size of pointers and architecture
Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?
Is there any mention of ghosts who live outside the Hogwarts castle?
Keeping the dodos out of the field
Real Analysis: Proof of the equivalent definitions of the derivative.
nginx conf: http2 module not working in Chrome in ubuntu 18.04
Loading multiple files from S3 to Redshift, query completing no data in tables
How to return multiple values from a function?Importing files from different folderHow can I open multiple files using “with open” in Python?How to install packages using pip according to the requirements.txt file from a local directory?How do I write JSON data to a file?Redshift load for snappy compressed fileloading the bulk data from s3 to redshiftUsing multiple manifest files to load to Redshift from S3?Python loads data from Redshift to S3JSON Data loading into Redshift Table
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a script firing from lambda that executes the following query:
COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?
Here is the code being executed in case this isn't a query issue:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.
python amazon-s3 amazon-redshift
add a comment |
I have a script firing from lambda that executes the following query:
COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?
Here is the code being executed in case this isn't a query issue:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.
python amazon-s3 amazon-redshift
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11
add a comment |
I have a script firing from lambda that executes the following query:
COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?
Here is the code being executed in case this isn't a query issue:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.
python amazon-s3 amazon-redshift
I have a script firing from lambda that executes the following query:
COPY test.error_log__c
FROM 's3://sfdc-etl-jp-test/sfdc_etl/json/error_log__c_json/2019/03/23/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
However, the tables are empty even though the query completes successfully. There are anywhere between 1 and 100 files in these paths. I am guessing that the copy command isn't smart enough to know what the file name is and that is why this isn't working. Am I right? if so how do I tell it to load multiple files?
Here is the code being executed in case this isn't a query issue:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execute(loadQuery).execution_options(autocommit=True)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
Note: Yes I know there are other queries, they are not shown as they are executing. Drop table, recreate table, re-apply permissions are all working and verified working. It is just the copy from S3 that is doing nothing.
python amazon-s3 amazon-redshift
python amazon-s3 amazon-redshift
edited Mar 23 at 21:57
Shenanigator
asked Mar 23 at 20:35
ShenanigatorShenanigator
293117
293117
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11
add a comment |
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11
add a comment |
1 Answer
1
active
oldest
votes
The answer is .... apparently order matters to sqlalchemy:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
you'll notice the order change to the auto_commit.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318114%2floading-multiple-files-from-s3-to-redshift-query-completing-no-data-in-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The answer is .... apparently order matters to sqlalchemy:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
you'll notice the order change to the auto_commit.
add a comment |
The answer is .... apparently order matters to sqlalchemy:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
you'll notice the order change to the auto_commit.
add a comment |
The answer is .... apparently order matters to sqlalchemy:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
you'll notice the order change to the auto_commit.
The answer is .... apparently order matters to sqlalchemy:
create_engine('postgres://:@/ibdrs'.format(igersUser, igersPwd, igersHost), encoding="utf-8")
loadQuery = '''
COPY .
FROM '/'
iam_role 'arn:aws:iam::<account>:role/LambdaFullAccessRole'
TRUNCATECOLUMNS
JSON 'auto'
EMPTYASNULL
TIMEFORMAT 'auto'
DATEFORMAT 'auto'
COMPUPDATE OFF
STATUPDATE ON
'''.format(igersSchema, nextObj, s3Destination, s3Path.format(nextObj), dated_path)
with igers.connect() as conn:
try :
conn.execute(drop_table)
print('completed drop table')
conn.execute(ddl_str)
print('completed create table')
conn.execution_options(autocommit=True).execute(loadQuery)
print('completed load query')
for row in range(len(groupPerms)) :
perms_statement = grantPerms.format(groupPerms['namespace'].iloc[row],groupPerms['item'].iloc[row],groupPerms['groname'].iloc[row])
conn.execute(perms_statement)
print('completed grant group permissions')
conn.close()
except exc.SQLAlchemyError as e :
print(e)
you'll notice the order change to the auto_commit.
answered Mar 23 at 22:21
ShenanigatorShenanigator
293117
293117
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318114%2floading-multiple-files-from-s3-to-redshift-query-completing-no-data-in-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
executing this directly on the redshift via navicat results in 132 records being added. why would this not work via EC2 / Lambda in a script with that role associated with them
– Shenanigator
Mar 23 at 20:46
I looked at the Redshift logs and there appears to be no difference between the queries the Redshift is seeing from manual execution via navicat and scripted execution via lambda. What else should I look at?
– Shenanigator
Mar 23 at 21:11