superfell / Beatbox

Beatbox is an easy to use Python Library for accessing the Salesforce.com API

Home Page:http://www.pocketsoap.com/beatbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 3.6.7 - wrong output

marekk1717 opened this issue · comments

Result of commands executed with beatbox on python 3.6 is a string combined from all fields, for inscante AccountStatusNameOK etc.
In python 2.7 result is returned as list.

I don't see any issues using python 3.7.3. Can you move to a newer version of python and/or provide an exact repro case.

it still doesn't work:
service = beatbox.Client() # instantiate the object
service.login(login, 'xxxxxxxxx') # login using your sf credentials
qr = service.query("select Id, Name from Attachment where ParentId='xxxxxxx' and Name='xxxxx'")

how shall I parse the output?

As far as Im aware, this doesn't change between python 2 and 3, you use the xmltamp features to access the results, e.g.

import sys
import beatbox
import xmltramp
import datetime

sf = beatbox._tPartnerNS
so = beatbox._tSObjectNS
svc = beatbox.Client()

svc.serverUrl = "https://login.salesforce.com/services/Soap/u/19.0"
loginResult = svc.login(sys.argv[1], sys.argv[2])
qr = svc.query("select id, subject from case limit 4")

# you can index into the records as an array
# offset 0 is the sobject type, offset 1 is the Id
# and then offset 2 onwards match the fields in the select list
print("by numerical index")
for rec in qr[sf.records:]:
	print(rec[0], rec[1], rec[2], rec[3])

print("or by field name")
# or you can index into it by name
for rec in qr[sf.records:]:
	print(rec[so.Id], rec[so.Subject])

generates for me, with python 3.7.3

by numerical index
Case 5003000000B7nTCAAZ 5003000000B7nTCAAZ Re: Message from Erik Brooks
Case 5003000000MEkRpAAL 5003000000MEkRpAAL FW: Office environment... Dog Style
Case 5003000000MC7dtAAD 5003000000MC7dtAAD FW: Reservation Confirmation
Case 5003000000L8ioeAAB 5003000000L8ioeAAB apex go boom
or by field name
5003000000B7nTCAAZ Re: Message from Erik Brooks
5003000000MEkRpAAL FW: Office environment... Dog Style
5003000000MC7dtAAD FW: Reservation Confirmation
5003000000L8ioeAAB apex go boom