cozodb/pycozo

Some errors in pycozo

Closed this issue · 2 comments

DerZc commented

Hi,

I want to try cozodb with python, but meet some errors. I try to connect to a server with client = Client('http', options={'host': 'http://127.0.0.1:9070'}), but I got the error message AttributeError: 'dict' object has no attribute 'host' triggered by https://github.com/cozodb/pycozo/blob/main/pycozo/client.py#L37, then I construct a class to pass this error, but I got another error AttributeError: 'Client' object has no attribute 'embedded' triggered by https://github.com/cozodb/pycozo/blob/main/pycozo/client.py#L222

I tried the embedded mode with example

rule[first, second, third] <- [[1, 2, 3], ['a', 'b', 'c']]
?[a, b, c] := rule[a, b, c]

But got this error message You need to have one rule named '?',

this is my python program:

from pycozo.client import Client
client = Client()
tx = client.multi_transact(True)
tx.run("rule[first, second, third] <- [[1, 2, 3], ['a', 'b', 'c']]")
r = tx.run("?[a, b, c] := rule[a, b, c]")
tx.commit()

Could you please tell me how to solve this? Thank you very much!

zh217 commented

The first problem has recently been fixed, for the moment please use the dev branch

pip install https://github.com/cozodb/pycozo/archive/dev.zip

For your second problem, you should put both rules in the same run script, and there is no need to use the transaction. Multi-statement transactions are rarely needed.

DerZc commented

I got it! Thank you for such a quick reply! I will try it!