cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
Hello All, I am using perl DBI in a perl script to pull information from an api, parse it and then enter it into a database.My code is as follows: So I put the api results in $api_results
$api_results=`curl -H "Authorization: token 5FEFAQ1W4" https://www.bom +/api/v2/organizations/company/admin/groups/"$groid"/installations?pag +e=1 > "$valid"; cat "$valid" | jq -r '(.[]|[.id, .slug, .name, .provi +der.id, .provider.name,.provider.capabilities.has_saml,.configuration +.saml,.configuration.login, .configuration.install_type, .created, .k +eyvault, .requires_mfa_code) | \@csv` ; ##insert statement $app_insert = $dbh->prepare("INSERT IGNORE INTO apps(id, app_slug, app +_Name, provider_id, provider_slug, provider_saml, config_saml, config +_login, config_url, created_date, status, key_vault, mfa_code) VALUES + (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?") or die $dbh->errstr; ##Insert execution while (my @api = $api_results->fetchrow_arr +ay()) { $app_insert->execute(@api) or die $app_inse +rt->errstr; } print "Done inserting \n"; exit; }
But after I execute the script, I get the following error, I think it is because i dont have api_results->execute() , but there is no statement to execute, so how can I make this work? Thank you
Total % Received % Xferd Average Speed Time Time Time Cu +rrent Dload Upload Total Spent Left + Speed 100 15573 100 15573 0 0 13102 0 0:00:01 0:00:01 --:--: +-- 83278 Can't call method "fetchrow_array" without a package or object referen +ce at bitium.pl line 70, <> line 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Database Entries
by huck (Prior) on Jul 14, 2017 at 05:02 UTC | |
by cbtshare (Monk) on Jul 14, 2017 at 23:46 UTC | |
by huck (Prior) on Jul 15, 2017 at 00:52 UTC | |
by cbtshare (Monk) on Jul 16, 2017 at 05:23 UTC | |
by huck (Prior) on Jul 16, 2017 at 05:34 UTC | |
| |
by cbtshare (Monk) on Jul 15, 2017 at 14:45 UTC | |
|
Re: Perl Database Entries
by roboticus (Chancellor) on Jul 14, 2017 at 05:30 UTC | |
by cbtshare (Monk) on Jul 14, 2017 at 23:48 UTC |