0

I am using a python module called phoenixdb to access phoenix which is SQL wrapper to query over HBase.

Here is my code snippet:-

import phoenixdb

database_url = 'http://localhost:8765/'
conn = phoenixdb.connect(database_url, autocommit=True)
cursor = conn.cursor()

cursor.execute("!table")
print cursor.fetchall()
cursor.close()

The phoenix query to list all the schemes and tables is !table or !tables. But when I try passing the same in the execute function as shown above, I get the following error:-

Traceback (most recent call last):
File "phoenix_hbase.py", line 7, in <module>
cursor.execute("!table")
File "build/bdist.linux-x86_64/egg/phoenixdb/cursor.py", line 242, in execute
File "build/bdist.linux-x86_64/egg/phoenixdb/avatica.py", line 345, in   prepareAndExecute
File "build/bdist.linux-x86_64/egg/phoenixdb/avatica.py", line 184, in _apply
File "build/bdist.linux-x86_64/egg/phoenixdb/avatica.py", line 90, in   parse_error_page
phoenixdb.errors.ProgrammingError: ("Syntax error. Unexpected char: '!'",   601, '42P00', None)

Funny part is when I try to passing a different query, for example a select query, then script gets executed and produces result just fine.

Query:cursor.execute("select * from CARETESTING.EDR_BIN_SOURCE_3600_EDR_FLOW_SUBS_TOTAL limit 1")

Result:
[[2045,1023,4567]]

Is there any other format for passing !table which is equivalent to show tables in phoenixdb library's execute function which I am missing?

I tried looking up on the internet but unfortunately haven't come across anything helpful so far.

Thanks

sam
  • 635
  • 4
  • 9
  • 18
  • `phoenixdb.errors.ProgrammingError: ("Syntax error. Unexpected char: '!'", 601, '42P00', None)` Which line is this pointing? – mertyildiran Jul 03 '16 at 16:56
  • Line 7 in the code. I have pasted above. – sam Jul 03 '16 at 17:00
  • OK then the problem is this query: `!table` So could you explain the purpose of this query? – mertyildiran Jul 03 '16 at 17:03
  • You know in sql/mysql , query to view tables is show tables. Similary, to view list of tables in phoenix shell, query is !table or !tables. – sam Jul 03 '16 at 17:09
  • It seems like `phoenixdb` package has an issue in this file: https://github.com/youngwookim/python-phoenixdb/blob/master/phoenixdb/avatica.py I can post the fix as the answer so you can fix the package and install manually, is it OK? – mertyildiran Jul 03 '16 at 17:16
  • can u please provide how and where to fix?Id highly appreciate it – sam Jul 03 '16 at 17:49
  • I will post it as an answer but it will take a little bit time. Please wait for my answer. – mertyildiran Jul 03 '16 at 17:55
  • Sure @mertyildiran. Thanks alot – sam Jul 03 '16 at 17:59
  • I couldn't recreate the same error on my machine. Please define each steps that you took to get this point on your question. – mertyildiran Jul 03 '16 at 18:17
  • @mertyildiran, Do u have phoenix installed on your system/server? – sam Jul 04 '16 at 06:27

1 Answers1

0

!tables is sqlline grammar that can not be parsed by JDBC interface.

sol
  • 225
  • 4
  • 17