Mysql as backend instead of flat files

This commit is contained in:
dave 2019-04-12 14:39:34 -07:00 committed by Dave Pedu
parent 0b3b766ec6
commit 388f10fb22
2 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,7 @@
import ZODB import ZODB
import ZODB.FileStorage from relstorage.storage import RelStorage
from relstorage.options import Options
from relstorage.adapters.mysql import MySQLAdapter
import persistent import persistent
import persistent.list import persistent.list
import persistent.mapping import persistent.mapping
@ -41,7 +43,9 @@ class NClassAttachment(persistent.Persistent):
class NodeOps(object): class NodeOps(object):
def __init__(self, db_path): def __init__(self, db_path):
self.storage = ZODB.FileStorage.FileStorage(db_path) self.mysql = MySQLAdapter(host="localhost", user="zodb", passwd="zodb", db="zodb",
options=Options(keep_history=False))
self.storage = RelStorage(adapter=self.mysql)
self.db = ZODB.DB(self.storage) self.db = ZODB.DB(self.storage)
with self.db.transaction() as c: with self.db.transaction() as c:

View File

@ -1,26 +1,35 @@
appdirs==1.4.3 appdirs==1.4.3
asn1crypto==0.24.0
backports.functools-lru-cache==1.5 backports.functools-lru-cache==1.5
BTrees==4.5.1 BTrees==4.5.1
certifi==2018.11.29 certifi==2018.11.29
cffi==1.12.2
chardet==3.0.4 chardet==3.0.4
cheroot==6.5.2 cheroot==6.5.2
CherryPy==18.0.1 CherryPy==18.0.1
cryptography==2.6.1
idna==2.8 idna==2.8
jaraco.functools==1.20 jaraco.functools==1.20
Jinja2==2.10 Jinja2==2.10
MarkupSafe==1.0 MarkupSafe==1.0
more-itertools==4.3.0 more-itertools==4.3.0
perfmetrics==2.0
persistent==4.4.2 persistent==4.4.2
portend==2.3 portend==2.3
pycparser==2.19
PyMySQL==0.9.3
pytz==2018.5 pytz==2018.5
PyYAML==3.13 PyYAML==3.13
RelStorage==2.1.1
requests==2.21.0 requests==2.21.0
six==1.11.0 six==1.11.0
tempora==1.13 tempora==1.13
transaction==2.2.1 transaction==2.4.0
urllib3==1.24.1 urllib3==1.24.1
zc.lockfile==1.3.0 zc.lockfile==1.3.0
ZConfig==3.3.0 ZConfig==3.3.0
ZODB==5.4.0 zdaemon==4.3
ZEO==5.2.1
ZODB==5.5.1
zodbpickle==1.0.2 zodbpickle==1.0.2
zope.interface==4.5.0 zope.interface==4.5.0