py2neo.client.config
– Client configuration¶
-
class
py2neo.client.config.
ConnectionProfile
(profile=None, **settings)[source]¶ Connection details for a Neo4j service.
A connection profile holds a set of values that describe how to connect to, and authorise against, a particular Neo4j service. The set of values held within a profile are available as either object attributes (e.g.
profile.uri
) or sub-items (e.g.profile["uri"]
.Profile instances are immutable, so can safely be hashed for inclusion within a set or as dictionary keys.
Parameters: - profile –
The base connection information, provided as a dictionary, an existing
ConnectionProfile
object or a string URI. This value can also beNone
, in which case default base settings are used.- (None) – no base profile; use default settings
- (str) – URI profile, e.g. bolt://bob@graph.example.com:7687
- (dict) – dictionary of individual settings
- (
ConnectionProfile
) – existing profile object
- settings –
An optional set of individual overrides for each value. Valid options are:
The values used for a default profile will be based on a local server listening on the default Bolt port, with the password
password
. These defaults can be altered via environment variables, if required:-
NEO4J_URI
¶
-
NEO4J_AUTH
¶
-
NEO4J_SECURE
¶
-
NEO4J_VERIFY
¶
The full set of attributes and operations are described below.
-
profile == other
Return
True
if profile and other are equal.
-
profile != other
Return
True
if profile and other are unequal.
-
hash(profile)
Return a hash of profile based on its contained values.
-
profile[key]
Return a profile value using a string key. Key names are identical to the corresponding attribute names.
-
len(profile)
Return the number of values encoded within this profile.
-
dict(profile)
Coerce the profile into a dictionary of key-value pairs.
-
address
¶ The full socket
Address
of the remote server. If unspecified, and uninfluenced by environment variables, this will default toIPv4Address(('localhost', 7687))
.
-
auth
¶ A 2-tuple of (user, password) representing the combined auth details. If unspecified, and uninfluenced by environment variables, this will default to
('neo4j', 'password')
.
-
classmethod
from_file
(filenames, section, prefix=None)[source]¶ Load profile information from a configuration file.
The required file format is described in the standard library
configparser
module, and is similar to that used in Windows INI files.Parameters: - filenames –
- section –
- prefix –
Returns: ConnectionProfile
object created from the loaded configuration
-
host
¶ The host name or IP address of the remote server. If unspecified, and uninfluenced by environment variables, this will default to
'localhost'
.
-
password
¶ The password which with to authorise. If unspecified, and uninfluenced by environment variables, this will default to
'password'
.
-
port
¶ The port to which to connect on the remote server. This will be the correct port for the given
protocol
. If unspecified, and uninfluenced by environment variables, this will default to7687
(for Bolt traffic).
-
port_number
¶ A variant of
port
guaranteed to be returned as a number. In some cases, the regular port value can be a string, this attempts to resolve or convert that value into a number. If unspecified, and uninfluenced by environment variables, this will default to7687
(for Bolt traffic).
-
protocol
¶ The name of the underlying point-to-point protocol, derived from the URI scheme. This will either be
'bolt'
or'http'
, regardless of security and verification settings. If unspecified, and uninfluenced by environment variables, this will default to'bolt'
.
-
scheme
¶ The URI scheme for contacting the remote server. If unspecified, and uninfluenced by environment variables, this will default to
'bolt'
.
-
secure
¶ A flag for whether or not to apply security to the connection. If unspecified, and uninfluenced by environment variables, this will default to
True
.
-
to_dict
(include_password=False)[source]¶ Convert this profile to a dictionary, optionally including password information.
Parameters: include_password – if True then include the password in the return value, otherwise omit this information (default)
-
uri
¶ A full URI for the profile. This generally includes all other information, excluding the password (for security reasons). If unspecified, and uninfluenced by environment variables, this will default to
'bolt://neo4j@localhost:7687'
.
-
user
¶ The user as whom to authorise. If unspecified, and uninfluenced by environment variables, this will default to
'neo4j'
.
-
verify
¶ A flag for verification of remote server certificates. If unspecified, and uninfluenced by environment variables, this will default to
True
.
- profile –