ZODB はオブジェクトデータベース管理システム
Ubuntu で OS のシステム更新を行うときは, 端末で,次のコマンドを実行する.
Ubuntu のインストールは別ページ »で説明
sudo apt -y update sudo apt -yV upgrade sudo /sbin/shutdown -r now
Python のインストールは行わない(Ubuntu のシステム Python を用いる.)
Python, pip のコマンドでの起動のまとめ.
Ubuntu のシステム Python を用いるとき, python, pip は,次のコマンドで起動できる.
Ubuntu での Python 開発環境(JupyterLab, spyder, nteract)のインストール: 別ページ »で説明
端末で,次のコマンドを実行する.
sudo apt -y update sudo apt -y install python-is-python3 python3-dev python-dev-is-python3 python3-pip python3-setuptools python3-venv build-essential
端末で,次のコマンドを実行する.
sudo pip3 install zodb
http://www.zodb.org/en/latest/documentation/tutorial.html (現存しない) に記載されていた account.py を使っている.
import persistent import ZODB, ZODB.FileStorage, ZODB.DB import BTrees.OOBTree class Account(persistent.Persistent): def __init__(self): self.balance = 0.0 def deposit(self, amount): self.balance += amount def cash(self, amount): assert amount < self.balance self.balance -= amount storage = ZODB.FileStorage.FileStorage('mydata.fs') db = ZODB.DB(storage) connection = db.open() root = connection.root # create one object root.accounts = BTrees.OOBTree.BTree() root.accounts['account-1'] = Account() root.accounts['account-1'].balance