Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'radb' has no attribute 'ast' #4

Closed
Ala-Jeb opened this issue Dec 13, 2020 · 1 comment
Closed

AttributeError: module 'radb' has no attribute 'ast' #4

Ala-Jeb opened this issue Dec 13, 2020 · 1 comment

Comments

@Ala-Jeb
Copy link

Ala-Jeb commented Dec 13, 2020

I have the following code:

import radb.parse dd = {} dd["Person"] = {"name": "string", "age": "integer", "gender": "string"} dd["Eats"] = {"name": "string", "pizza": "string"} stmt = """\project_{Person.name, Eats.pizza} \select_{Person.name = Eats.name}(Person \cross Eats);""" ra = radb.parse.one_statement_from_string(stmt) print(ra)

It shows me the following error
Traceback (most recent call last):
File "test.py", line 9, in
ra = one_statement_from_string(stmt)
File "/home/alajeb/.local/lib/python3.6/site-packages/radb/parse.py", line 262, in one_statement_from_string
ast = ASTBuilder().visit(tree)
File "/home/alajeb/.local/lib/python3.6/site-packages/antlr4/tree/Tree.py", line 34, in visit
return tree.accept(self)
File "/home/alajeb/.local/lib/python3.6/site-packages/radb/RAParser.py", line 1745, in accept
return visitor.visitStatement(self)
File "/home/alajeb/.local/lib/python3.6/site-packages/radb/parse.py", line 247, in visitStatement
return self.visit(ctx.getChild(0))
File "/home/alajeb/.local/lib/python3.6/site-packages/antlr4/tree/Tree.py", line 34, in visit
return tree.accept(self)
File "/home/alajeb/.local/lib/python3.6/site-packages/radb/RAParser.py", line 972, in accept
return visitor.visitProjectExpr(self)
File "/home/alajeb/.local/lib/python3.6/site-packages/radb/parse.py", line 175, in visitProjectExpr
return radb.ast.Project(self.visit(ctx.listOfValExprs()), self.visit(ctx.relExpr()))
AttributeError: module 'radb' has no attribute 'ast'

@junyang
Copy link
Owner

junyang commented Jul 27, 2021

radb isn't yet designed to be use as a library, but to get around the particular problem that you are facing, you can try:

from radb import parse, ast
stmt = """\project_{Person.name, Eats.pizza} \select_{Person.name = Eats.name}(Person \cross Eats);"""
ra = parse.one_statement_from_string(stmt)
print(ra)

--- Jun Y.

@junyang junyang closed this as completed Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants