pfunk.client
View Source
from envs import env from faunadb.client import FaunaClient as FC from faunadb import query as q from faunadb.objects import Ref class FaunaClient(FC): def __init__( self, secret=None, domain=env('FAUNA_DOMAIN', 'db.fauna.com'), scheme=env('FAUNA_SCHEME', "https"), port=None, timeout=60, observer=None, pool_connections=10, pool_maxsize=10, **kwargs) -> None: """ Args: secret (str, required, default=None): Auth token for the FaunaDB server. domain (str, optional, default="db.fauna.com"): Base URL for the FaunaDB server. scheme (str, optional, default="https"): ``"web"`` or ``"https"``. port (int, optional, default=None): Port of the FaunaDB server. timeout (int, optional, default=60): Read timeout in seconds. observer (optional, default=None): Callback that will be passed a :any:`RequestResult` after every completed request. pool_connections (int, optional, default=10): The number of connection pools to cache. pool_maxsize (int, optional, default=10): The maximum number of connections to save in the pool. """ self.secret = secret or env('FAUNA_SECRET') env_port = env('FAUNA_PORT') if env_port: port = int(env_port) if not self.secret: raise ValueError('When creating a FaunaClient instance you must supply the secret argument or set the ' 'FAUNA_SECRET environment variable.') # pragma: no cover super(FaunaClient, self).__init__(secret, domain=domain, scheme=scheme, port=port, timeout=timeout, observer=observer, pool_connections=pool_connections, pool_maxsize=pool_maxsize, **kwargs)
View Source
class FaunaClient(FC): def __init__( self, secret=None, domain=env('FAUNA_DOMAIN', 'db.fauna.com'), scheme=env('FAUNA_SCHEME', "https"), port=None, timeout=60, observer=None, pool_connections=10, pool_maxsize=10, **kwargs) -> None: """ Args: secret (str, required, default=None): Auth token for the FaunaDB server. domain (str, optional, default="db.fauna.com"): Base URL for the FaunaDB server. scheme (str, optional, default="https"): ``"web"`` or ``"https"``. port (int, optional, default=None): Port of the FaunaDB server. timeout (int, optional, default=60): Read timeout in seconds. observer (optional, default=None): Callback that will be passed a :any:`RequestResult` after every completed request. pool_connections (int, optional, default=10): The number of connection pools to cache. pool_maxsize (int, optional, default=10): The maximum number of connections to save in the pool. """ self.secret = secret or env('FAUNA_SECRET') env_port = env('FAUNA_PORT') if env_port: port = int(env_port) if not self.secret: raise ValueError('When creating a FaunaClient instance you must supply the secret argument or set the ' 'FAUNA_SECRET environment variable.') # pragma: no cover super(FaunaClient, self).__init__(secret, domain=domain, scheme=scheme, port=port, timeout=timeout, observer=observer, pool_connections=pool_connections, pool_maxsize=pool_maxsize, **kwargs)
Directly communicates with FaunaDB via JSON.
For data sent to the server, the to_fauna_json
method will be called on any values.
It is encouraged to pass e.g. :any:Ref
objects instead of raw JSON data.
All methods return a converted JSON response.
This is a dict containing lists, ints, floats, strings, and other dicts.
Any :any:Ref
, :any:SetRef
, :any:FaunaTime
, or datetime.date
values in it will also be parsed.
(So instead of {"@ref": {"id": "frogs", "class": {"@ref": {"id": "classes"}}}}
,
you will get Ref("frogs", Native.CLASSES)
.)
#  
FaunaClient(
secret=None,
domain='fauna',
scheme='http',
port=None,
timeout=60,
observer=None,
pool_connections=10,
pool_maxsize=10,
**kwargs
)
View Source
def __init__( self, secret=None, domain=env('FAUNA_DOMAIN', 'db.fauna.com'), scheme=env('FAUNA_SCHEME', "https"), port=None, timeout=60, observer=None, pool_connections=10, pool_maxsize=10, **kwargs) -> None: """ Args: secret (str, required, default=None): Auth token for the FaunaDB server. domain (str, optional, default="db.fauna.com"): Base URL for the FaunaDB server. scheme (str, optional, default="https"): ``"web"`` or ``"https"``. port (int, optional, default=None): Port of the FaunaDB server. timeout (int, optional, default=60): Read timeout in seconds. observer (optional, default=None): Callback that will be passed a :any:`RequestResult` after every completed request. pool_connections (int, optional, default=10): The number of connection pools to cache. pool_maxsize (int, optional, default=10): The maximum number of connections to save in the pool. """ self.secret = secret or env('FAUNA_SECRET') env_port = env('FAUNA_PORT') if env_port: port = int(env_port) if not self.secret: raise ValueError('When creating a FaunaClient instance you must supply the secret argument or set the ' 'FAUNA_SECRET environment variable.') # pragma: no cover super(FaunaClient, self).__init__(secret, domain=domain, scheme=scheme, port=port, timeout=timeout, observer=observer, pool_connections=pool_connections, pool_maxsize=pool_maxsize, **kwargs)
Args
- secret (str, required, default=None): Auth token for the FaunaDB server.
- domain (str, optional, default="db.fauna.com"): Base URL for the FaunaDB server.
- scheme (str, optional, default="https"):
"web"
or"https"
. - port (int, optional, default=None): Port of the FaunaDB server.
- timeout (int, optional, default=60): Read timeout in seconds.
- observer (optional, default=None): Callback that will be passed a :any:
RequestResult
after every completed request. - pool_connections (int, optional, default=10): The number of connection pools to cache.
- pool_maxsize (int, optional, default=10): The maximum number of connections to save in the pool.
Inherited Members
- faunadb.client.FaunaClient
- sync_last_txn_time
- get_last_txn_time
- get_query_timeout
- query
- stream
- ping
- new_session_client