AMIV SugarCRM的简单连接
amivcrm的Python项目详细描述
AMIV SugarCRM的连接器
sugarcrm提供了soap和rest api。在写这个工具的时候 很遗憾,REST api不可用因此使用肥皂。
使用python库suds,更确切地说是fork by jurko。
安装
pip install amivcrm
用法
您需要一个soap用户名和密码你可以在 AMIV Wiki。 拿到证书后,就这么简单了:
from amivcrm import AMIVCRM
CRM = AMIVCRM(username, password)
# Optional: Specify `url` and/or `appname`
# CRM = AMIVCRM(username, password, url="...", appname="...")
# Get Companies
CRM.get('Accounts')
# Select only certain fields
# Filter and order with SQL statements
CRM.get('Accounts',
# Only companies participating in job fair
query="accounts_cstm.messeteilnahme_c = 1",
# Order alphabetically
order_by="accounts.name",
# Return Name and ID only
select_fields=['name', 'id'])
# Get a single company by id
CRM.getentry('Accounts', '505404b1-1851-1472-d63e-4d829377e30b',
# Optional: Limit the returned fields as well
select_fields=['name'])
# Get a company only if modified after given date
entry_id = '505404b1-1851-1472-d63e-4d829377e30b'
date = '2016-03-20 08:05:39'
# Be careful to use quotes in query
query = ("accounts.id = '%s' and accounts.date_modified >= '%s'"
% (entry_id, date))
CRM.get('Accounts', query=query)