Skip to content

Commit

Permalink
do rethinkdb table properly
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Mar 31, 2015
1 parent 00101d1 commit 40e1c90
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tornado_app.py
Expand Up @@ -631,19 +631,11 @@ def _create_talks_es(self, how_many, callback):
duration=_random_duration()
)
document['when'] = time.mktime(document['when'].timetuple())
#document['id'] = uuid.uuid4().hex
r = self.es.index(
'talks',
'talk',
document)
ids.add(r['_id'])
#docs.append(document)
#results = self.es.bulk_index(
# 'talks',
# 'talk',
# docs
#)
#ids = [x['create']['_id'] for x in results['items']]
callback(ids)

@gen.engine
Expand Down Expand Up @@ -1113,11 +1105,13 @@ def _random_duration():
if rethinkdb:
conn = rethinkdb.connect()

# if 'talks' not in rethinkdb.db_list().run(application.rethinkdb):
rethinkdb.db_drop('talks').run(conn)
rethinkdb.db_create('talks').run(conn)
if 'talks' not in rethinkdb.db_list().run(conn):
# rethinkdb.db_drop('talks').run(conn)
rethinkdb.db_create('talks').run(conn)
conn.use('talks')
try:
rethinkdb.db('talks').table_create('talks')
# rethinkdb.db('talks').table_create('talks', durability='soft').run(conn)
rethinkdb.db('talks').table_create('talks').run(conn)
except rethinkdb.RqlRuntimeError:
print "rethinkdb table already existed"
application.rethinkdb = conn
Expand Down

0 comments on commit 40e1c90

Please sign in to comment.