from rethinkdb import RethinkDB
r = RethinkDB()
r.connect( host='192.156.213.164', port=28015, db='test', user='redbteam', password='password.01' ).repl()
DB = "test"
TABLE = "events"

if DB not in r.db_list().run():
    r.db_create(DB).run()

if TABLE not in r.db(DB).table_list().run():
    r.db(DB).table_create(TABLE).run()

# indice su type
if "type" not in r.db(DB).table(TABLE).index_list().run():
    r.db(DB).table(TABLE).index_create("type").run()
    r.db(DB).table(TABLE).index_wait("type").run()

print("Database and table ready.")
