Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Attached is a new drush include file that enables you to use the command line to query your salesforce data. It adds three new commands to drush:
- "soql show tables" Basically mimicks mysql's show tables, ie it lists out what object types can run soql queries against.
- "soql describe" Lets you inspect a object (and it's components) in salesfoce
- "soql" Run a soql query from the command line! yay.
Hope it's useful.
Comment | File | Size | Author |
---|---|---|---|
#9 | salesforce_api.drush_.inc_.2.txt | 6.43 KB | jmiccolis |
#1 | salesforce_api.drush_.inc_.txt | 4.27 KB | jmiccolis |
Comments
Comment #1
jmiccolis CreditAttribution: jmiccolis commentedFile uploading didn't take. take two.
Comment #2
alex_b CreditAttribution: alex_b commentedWe're using this in production for exploring SF repositories and building queries. This really makes our work faster.
Setting to needs review.
Comment #3
Bevan CreditAttribution: Bevan commentedOh goodie! I wish I'd had this a week ago! :)
Comment #4
Bevan CreditAttribution: Bevan commentedI put the file in /salesforce_api/salesforce_api.drush.inc.
I can see all 3 SOQL commands in drush help, but I get the following error when I try to run any soql command
Fatal error: Class 'SoapClient' not found in [snip]/SforceBaseClient.php on line 121
. admin/settings/salesforce/demo connects fine.Comment #5
AaronBaumanA buddy of mine ran into this yesterday.
salesforce module works fine through your browser, right?
so, my guess is that your command line php instance is
1) different from your web php instance (for example if you're using X/M/WAMP) and
2) not configured with --enable-soap
try executing drush with the exact same php instance you use for apache.
Comment #6
Bevan CreditAttribution: Bevan commentedGood spotting. That was the issue – Thanks! Since Drush is a tool for development environments, I think we need to handle this error a bit better. E.g. "Have you enabled SOAP? If you can connect through the browser, make sure your command line PHP binary is the same as your web server's PHP binary. Use the command which php to help determine what binary is being used on the CLI."
Also, the help documents need fleshing out. The all need at least one example, in the same format as other Drush help docs. The soql command needs a few examples, some which actually work in most SF environments. It also needs links on how to find out more about how to use soql, and what soql is.
Otherwise, this is totally awesome and RTBC.
Comment #7
jmiccolis CreditAttribution: jmiccolis commentedGreat, glad everybody else if finding this useful. I'll post and updated file later this week which checks php compat and has some better docs.
Comment #8
jmiccolis CreditAttribution: jmiccolis commentedI've added better help, better display on soql describe when fields are requested, and now check for the soap extension.
Comment #9
jmiccolis CreditAttribution: jmiccolis commentedfile upload failed, trying again.
Comment #10
Bevan CreditAttribution: Bevan commentedComment #11
Bevan CreditAttribution: Bevan commentedCommitted in #208928 to DRUPAL-6--2. Nice work, and nice blog post! :)
Comment #13
victorkane CreditAttribution: victorkane commentedHave been enjoying this for some time.
Yesterday switched to new All-Versions-2.0 Drush, which is working fine; however, when I use the "drush soql" commands that were working fine previously, now I get invisible output.
The query is made ok, and the data returned from SF, but the data itself is not printed. For example:
$ drush soql show tables
... (142 lines) ...
142 rows in set.
Another example:
$ drush soql select Id from Contact where Email = \'someone@someone.net\'
1 rows in set (2.68 sec)
Programmatically, I am getting data, so I wonder if this is happening to anyone else using "drush soql" commands with the All-Versions-2.0 drush release.
Again, thanks a million for this wonderful drush extension!
Comment #14
jmiccolis CreditAttribution: jmiccolis commentedyes, the drush table printing api changed recently. This should be a quick fix
Comment #15
Bevan CreditAttribution: Bevan commentedThis is a separate issue, please create a new ticket/issue-node.