pymapd icon indicating copy to clipboard operation
pymapd copied to clipboard

Add auto-wakeup functionality to connect (OmniSci Cloud)

Open randyzwitch opened this issue 6 years ago • 1 comments
trafficstars

On the Community board, Veda posted an interesting solution for retrying to connect against OmniSci Cloud:

import time
from pymapd import connect

# Establish connection to MapD Cloud Instance
def connect_to_mapd(str_user, str_password, str_host, str_dbname):
 try:
   connection = connect(user=str_user, password=str_password, host=str_host, dbname=str_dbname, port=443, protocol='https')
 except Exception as ex:
   template = "An exception of type {0} occurred. Arguments:\n{1!r}"
   message = template.format(type(ex).__name__, ex.args)
   print(message)
   if 'OmniSci Core not ready, try again' in message:
     print("Set connection to RETRY!")
     connection = "RETRY"
   else:
     print("Set connection to ERROR!")
     connection = "ERROR"    

 return connection

We should incorporate this sort of functionality in pymapd.connect (after evaluating what is the correct way to do this, which may/may not be what Veda posted, as I haven't evaluated this code)

randyzwitch avatar Dec 03 '18 14:12 randyzwitch

@omveda Here's the issue I was talking about, it'd be great if you cleaned this up and submitted a PR

randyzwitch avatar Feb 08 '19 18:02 randyzwitch