import time
import rethinkdb as r
r.connect( "localhost", 28015).repl()
#r.db("test").table_create("authors").run()
"""r.table("authors").insert([
   { "name": "William Adama", "tv_show": "Battlestar Galactica",
     "posts": [
       {"title": "Decommissioning speech", "content": "The Cylon War is long over..."},
     {"title": "We are at war", "content": "Moments ago, this ship received..."},
      {"title": "The new Earth", "content": "The discoveries of the past few days..."}      ]
    },
    { "name": "Laura Roslin", "tv_show": "Battlestar Galactica",
       "posts": [
        {"title": "The oath of office", "content": "I, Laura Roslin, ..."},
        {"title": "They look like us", "content": "The Cylons have the ability..."}
       ]
     },
     { "name": "Jean-Luc Picard", "tv_show": "Star Trek TNG",
       "posts": [
         {"title": "Civil rights", "content": "There are some words I've known since..."}
       ]
     }]).run()"""
isStarted = False
printOnce = True
i =0 
print "Client"
while(True):
	try:
		
		cursor = r.table("authors").run()
		t1 = time.clock()
		if printOnce == False:
			print str(t1-t0)
			printOnce = True
			isStarted = False
			i = 0
	except:
		i+=1
		#print "mpika" + str(i)
		if isStarted == False:
			t0 = time.clock()			
			isStarted = True
			printOnce = False
			
		#time.sleep(5)



