records
records copied to clipboard
circular reference detected for minimal query
I'm getting a circular reference when attempting to do a very simple query:
$cat test.py
import records
def retrieve():
db = records.Database("postgres://localhost/pocket_replacement")
rows = db.query(
"""SELECT document_id FROM root;""")
for row in rows:
print(row)
if __name__ == "__main__":
retrieve()
$python3 test.py
Traceback (most recent call last):
File "test.py", line 14, in <module>
retrieve()
File "test.py", line 11, in retrieve
print(row)
File "/usr/local/lib/python3.6/site-packages/records.py", line 35, in __repr__
return '<Record {}>'.format(self.export('json')[1:-1])
File "/usr/local/lib/python3.6/site-packages/records.py", line 95, in export
return self.dataset.export(format, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tablib/core.py", line 467, in export
return export_set(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tablib/formats/_json.py", line 31, in export_set
return json.dumps(dataset.dict, default=date_handler)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
ValueError: Circular reference detected
Python is version 3.6, records is version 0.5.0.
A similar records call:
$records "SELECT url from root;" csv --url="postgres://localhost/pocket_replacement"
returns results, so I'm not sure what is going on here.
Is the issue still valid? Is it happening with the latest records version? If so. could you provide small example of data to reproduce the problem?
$ pip freeze would be helpful too (to see, what JSON encoding libraries are in place and what tablib version you have).