All Projects → plangrid → soql

plangrid / soql

Licence: MIT license
Models and query generator for Salesforce Object Query Language (SOQL)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to soql

Public-Method-CardGame-NiuNiu
纸牌游戏牛牛的最优算法及Method
Stars: ✭ 21 (+31.25%)
Mutual labels:  public
Maaslin2
MaAsLin2: Microbiome Multivariate Association with Linear Models
Stars: ✭ 76 (+375%)
Mutual labels:  public
humann
HUMAnN 3.0 is the next generation of HUMAnN 1.0 (HMP Unified Metabolic Analysis Network).
Stars: ✭ 95 (+493.75%)
Mutual labels:  public
melonnpan
Model-based Genomically Informed High-dimensional Predictor of Microbial Community Metabolic Profiles
Stars: ✭ 20 (+25%)
Mutual labels:  public
jitsi-box
A Raspberry Pi based box to automate holding hybrid conferences with Jitsi
Stars: ✭ 15 (-6.25%)
Mutual labels:  public
OctopusCLI
| Public | Command line tool for Octopus Deploy
Stars: ✭ 40 (+150%)
Mutual labels:  public
openfpc
A 2D CAD tool built on React, Three.js, and Immutable
Stars: ✭ 34 (+112.5%)
Mutual labels:  public
OctopusTentacle
| Public | The secure, lightweight, cross-platform agent for Octopus Server which turns any computer into a worker or deployment target for automated deployments and operations runbooks.
Stars: ✭ 25 (+56.25%)
Mutual labels:  public
Public Apis
A collective list of free APIs
Stars: ✭ 177,707 (+1110568.75%)
Mutual labels:  public
strongs-dictionary-xml
Strong's Greek Dictionary in XML with real Greek
Stars: ✭ 65 (+306.25%)
Mutual labels:  public
ficus
Scala-friendly companion to Typesafe config
Stars: ✭ 321 (+1906.25%)
Mutual labels:  public
babel-plugin-private-underscores
Make _classMembers 'private' using symbols
Stars: ✭ 39 (+143.75%)
Mutual labels:  public
content
Scripts & code for use with Guardian
Stars: ✭ 13 (-18.75%)
Mutual labels:  public
masader
The largest public catalogue for Arabic NLP and speech datasets. There are +250 datasets annotated with more than 25 attributes.
Stars: ✭ 66 (+312.5%)
Mutual labels:  public
octopackjs
A nodejs tool for packaging and pushing projects to an Octopus Deploy instance.
Stars: ✭ 26 (+62.5%)
Mutual labels:  public
kneaddata
Quality control tool on metagenomic and metatranscriptomic sequencing data, especially data from microbiome experiments.
Stars: ✭ 52 (+225%)
Mutual labels:  public
googletranslate
Python Google Translate (using reverse-engineered public API, so free)
Stars: ✭ 67 (+318.75%)
Mutual labels:  public
push-package-action
| Public | GitHub Action to Push a Package to Octopus Deploy
Stars: ✭ 23 (+43.75%)
Mutual labels:  public
latch-plugin-unix
No description or website provided.
Stars: ✭ 20 (+25%)
Mutual labels:  public
fbdl
📥 Download publicly shared videos from Facebook with an ease!
Stars: ✭ 29 (+81.25%)
Mutual labels:  public

SOQL

CI Status PyPI status

This package provides declarative models for Salesforce objects and utilities for generating Salesforce Object Query Language (SOQL) queries from these models.

This package works well with Simple Salesforce.

Usage

from simple_salesforce import Salesforce
from soql import attributes
from soql import load_models_from_salesforce_data
from soql import Model
from soql import select


class Account(Model):
    id = attributes.String('Id')
    deleted = attributes.Boolean('IsDeleted')
    name = attributes.String('Name')
    owner = attributes.Relationship('Owner', related_model=User)
    custom_field = attributes.String('CustomField__c', nullable=True)

class User(Model):
    id = attributes.String('Id')
    email = attributes.String('Email')

sf = Salesforce(...)

query = select(Account) \
    .where(Account.id == '50130000000014c') \
    .join(Account.owner)

resp = sf.query(str(query))

account = load_models_from_salesforce_data(resp)[0]

print(account.id)
print(account.owner.id)

Models

Models define in-memory representations of Salesforce object, and provide an idiomatic way to access the data.

from soql import attributes
from soql import Model

class User(Model):
    # The first argument to an attribute is its name in Salesforce.
    id = attributes.String('Id')
    email = attributes.String('Email')

user = User(id='123', email='[email protected]')

assert user.id == '123'

Helpers are available to load models directly from simple_salesforce:

query = select(User)

resp = sf.query(str(query))

users = load_models_from_salesforce_data(resp)

Relationships can also be declared:

class Account(Model):
    id = attributes.String('Id')
    owner = attributes.Relationship('Owner', related_model=User)
    contacts = attributes.Relationship('Contacts', related_model=User, many=True)

Queries

SOQL queries can be generated from models:

from soql import select

query = select(User).where(User.id == '123')

assert str(query) == "SELECT User.Id, User.Email FROM User WHERE User.Id = '123'"

Most of SOQL is supported, including...

Joins:

from soql import select

query = select(Account).join(Account.contacts)

assert str(query) == "SELECT Account.Id, (SELECT User.Id, User.Email FROM Account.Contacts) FROM Account"

Subqueries:

from soql import select

subquery = select(User).columns(User.email).subquery()
query = select(User).where(User.email.in_(subquery))

assert str(query) == "SELECT User.Id, User.Email FROM User WHERE User.Email IN (SELECT User.Email FROM User)"

And more!

Installation

pip install soql

Contributing

There is still work to be done, and contributions are encouraged! Check out the contribution guide for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].