I was using Pyrseas package for database comparison between my clusters. In fact, I am using it for more complex cases and it’s been very helpful. Unfortunately, there is a bug that I encountered recently.
Both dbtoyaml and yamltodb are needed for my cases and the command is mainly do as follow:
dbtoyaml --host=localhost --port=5433 sai_database --output=sai_database.yaml
After some processes are running, this throws an error below:
Traceback (most recent call last): File "/Users/sai/.local/bin/dbtoyaml", line 11, in <module> sys.exit(main()) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbtoyaml.py", line 49, in main dbmap = db.to_map() File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/database.py", line 487, in to_map dbmap.update(self.db.schemas.to_map(self.db, opts)) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/schema.py", line 355, in to_map schemas.update(self[sch].to_map(db, self, opts)) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/schema.py", line 104, in to_map schobjs.append((obj, obj.to_map(db, dbschemas, opts))) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/table.py", line 525, in to_map tbls[self.foreign_keys[k.name].ref_table].column_names())) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/constraint.py", line 486, in to_map dct = super(ForeignKey, self).to_map(db) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/__init__.py", line 368, in to_map deps -= self.get_implied_deps(db) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/constraint.py", line 564, in get_implied_deps idx = self._find_referenced_index(db, self._references) File "/Users/sai/.local/lib/python3.4/site-packages/pyrseas/dbobject/constraint.py", line 576, in _find_referenced_index if uc.columns == self.ref_cols: AttributeError: 'dict' object has no attribute 'columns'
I’ve asked around and nobody seems to know what is going on. So, I look this up and found out that there is a small bug in Pyrseas 0.8.0 which caused this.
Apparently the problem is in line 581 which is
uc.columns. You can change that line to
uc["columns"] and retry to re-build it.
But, this bug is easily fixed in this commit. So, you don’t have to build it yourself. Instead, just install the Pyrseas package with command as follow:
pip install git+https://github.com/perseas/Pyrseas/tree/r0.8
This means that you will install Pyrseas packages which is version 0.8.x. There’s no clear information when the new release will be out. I have to argue with my colleague for this case but there’s no other option except this workaround. For now.