AccountInfo stores basic information about the account, such as Application Key ID and Application Key, in order to let :pyb2sdk.v1.B2Api
perform authenticated requests.
There are two usable implementations provided by b2sdk:
- :py
b2sdk.v1.InMemoryAccountInfo
- a basic implementation with no persistence- :py
b2sdk.v1.SqliteAccountInfo
- for console and GUI applications
They both provide the full AccountInfo interface <account_info_interface>
.
Note
Backup applications and many server-side applications should implement their own <my_account_info>
AccountInfo, backed by the metadata/configuration database of the application.
AccountInfo with no persistence.
b2sdk.v1.InMemoryAccountInfo()
Implements all methods of AccountInfo interface <account_info_interface>
.
Hint
Usage of this class is appropriate for secure Web applications which do not wish to persist any user data.
Using this class for applications such as CLI, GUI or backup is discouraged, as InMemoryAccountInfo
does not write down the authorization token persistently. That would be slow, as it would force the application to retrieve a new one on every command/click/backup start. Furthermore - an important property of AccountInfo is caching the bucket_name:bucket_id
mapping; in case of InMemoryAccountInfo
the cache will be flushed between executions of the program.
__init__()
The constructor takes no parameters.
b2sdk.v1.SqliteAccountInfo()
Implements all methods of AccountInfo interface <account_info_interface>
.
Uses a SQLite database for persistence and access synchronization between multiple processes. Not suitable for usage over NFS.
Underlying database has the following schema:
/dot/sqlite_account_info_schema.dot
Hint
Usage of this class is appropriate for interactive applications installed on a user's machine (i.e.: CLI and GUI applications).
Usage of this class might be appropriate for non-interactive applications installed on the user's machine, such as backup applications. An alternative approach that should be considered is to store the AccountInfo data alongside the configuration of the rest of the application.
When building a server-side application or a web service, you might want to implement your own AccountInfo class backed by a database. In such case, you should inherit from :pyb2sdk.v1.UrlPoolAccountInfo
, which has groundwork for url pool functionality). If you cannot use it, inherit directly from :pyb2sdk.v1.AbstractAccountInfo
.
>>> from b2sdk.v1 import UrlPoolAccountInfo
>>> class MyAccountInfo(UrlPoolAccountInfo):
...
:pyb2sdk.v1.AbstractAccountInfo
describes the interface, while :pyb2sdk.v1.UrlPoolAccountInfo
and :pyb2sdk.v1.UploadUrlPool
implement a part of the interface for in-memory upload token management.
b2sdk.v1.AbstractAccountInfo()
b2sdk.v1.UrlPoolAccountInfo()
Caution
This class is not part of the public interface. To find out how to safely use it, read this <semantic_versioning>
.
b2sdk.account_info.upload_url_pool.UploadUrlPool()
Caution
This class is not part of the public interface. To find out how to safely use it, read this <semantic_versioning>
.