Table in database


#1

how to check whether a database contains table using pymapd
if it contains table then database name must be included in mapd url
eg


#2

Good morning @nagulan -

You should be able to do this using base functionality in Python, as far as I can tell there is nothing pymapd specific here.

Per this other thread, you can get the list of tables from the get_tables() method in pymapd.

From there, you can do something like:

tbl = conn.get_tables()
if "AthenaFinance" in tbl:
    url = 'mapd://mapd:HyperInteractive@deepbox.thickdata.io:9091/AthenaFinance’

Or you could use string substitution, since your base url of mapd://mapd:HyperInteractive@deepbox.thickdata.io:9091/ seems to be constant. Or write a function…how to solve this problem is dependent on how robust you want to make the solution, but again, it’s all just standard python code.