本文整理汇总了Python中rethinkdb.table_create函数的典型用法代码示例。如果您正苦于以下问题:Python table_create函数的具体用法?Python table_create怎么用?Python table_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了table_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initialSetup
def initialSetup():
print "Setting up database..."
dbs = rethinkdb.db_list().run()
if not con.general.databases["rethink"]["db"] in dbs:
print "Creating database in rethink"
rethinkdb.db_create(con.general.databases["rethink"]["db"]).run()
dbt = list(rethinkdb.table_list().run())
for db in c.general.flush["rethink"]:
if c.general.flush["rethink"][db]:
print "Flushing rethink "+db+" table..."
if db in dbt:
rethinkdb.table_drop(db).run()
dbt.pop(dbt.index(db))
print "Creating new rethink tables..."
for table in c.general.tables:
if not table in dbt:
print "Creating table {}".format(table)
rethinkdb.table_create(table).run()
for key in c.general.flush["redis"]:
if c.general.flush["redis"][key]:
print "Flushing redis "+key+" keys..."
keys = con.redis.keys(key+":*")
for key in keys: con.redis.delete(key)
开发者ID:JoshAshby,项目名称:psh,代码行数:27,代码来源:firstTime.py
示例2: __init__
def __init__(self, database='apscheduler', table='jobs', client=None,
pickle_protocol=pickle.HIGHEST_PROTOCOL, **connect_args):
super(RethinkDBJobStore, self).__init__()
self.pickle_protocol = pickle_protocol
if not database:
raise ValueError('The "database" parameter must not be empty')
if not table:
raise ValueError('The "table" parameter must not be empty')
if client:
self.conn = maybe_ref(client)
else:
self.conn = r.connect(db=database, **connect_args)
if database not in r.db_list().run(self.conn):
r.db_create(database).run(self.conn)
if table not in r.table_list().run(self.conn):
r.table_create(table).run(self.conn)
if 'next_run_time' not in r.table(table).index_list().run(self.conn):
r.table(table).index_create('next_run_time').run(self.conn)
self.table = r.db(database).table(table)
开发者ID:cychenyin,项目名称:windmill,代码行数:25,代码来源:rethinkdb.py
示例3: create_tables
def create_tables(tables):
"""
"""
existing_tables = r.table_list().run(conn)
for table in tables:
if table not in existing_tables:
r.table_create(table).run(conn)
开发者ID:rmechler,项目名称:mytunes,代码行数:7,代码来源:test.py
示例4: init_database
def init_database():
try:
connection = r.connect(host=RDB_HOST, port=RDB_PORT, db=RDB_DB)
except RqlDriverError:
debug("Could not connect to the database %s:%d, exiting..." % (RDB_HOST, RDB_PORT), True)
exit(1)
try:
r.db_create("tomatoesfridge").run( connection )
except r.errors.RqlRuntimeError as e:
# We could parse the error... later...
debug("Database `tomatoesfridge` not created. Reason:")
debug(str(e))
else:
debug("Database `tomatoesfridge` created")
try:
r.table_create("movie").run( connection )
except r.errors.RqlRuntimeError as e:
# We could parse the error... later...
debug("Table `movie` in `tomatoesfridge` not created. Reason")
debug(str(e))
else:
debug("Table `movie` in `tomatoesfridge` created")
try:
connection.close()
except AttributeError:
debug("Could not close a connection", True)
pass
开发者ID:neumino,项目名称:tomatoesfridge,代码行数:30,代码来源:server.py
示例5: rethinkdb
def rethinkdb():
"""Prepare database and table in RethinkDB"""
from rethinkdb.errors import ReqlOpFailedError, ReqlRuntimeError
conn = r.connect(host=conf.RethinkDBConf.HOST)
# Create database
try:
r.db_create(conf.RethinkDBConf.DB).run(conn)
click.secho('Created database {}'.format(conf.RethinkDBConf.DB),
fg='yellow')
except ReqlOpFailedError:
click.secho('Database {} already exists'.format(conf.RethinkDBConf.DB),
fg='green')
# Create table 'domains'
conn = r.connect(host=conf.RethinkDBConf.HOST,
db=conf.RethinkDBConf.DB)
try:
r.table_create('domains', durability=conf.RethinkDBConf.DURABILITY).\
run(conn)
click.secho('Created table domains', fg='yellow')
except ReqlOpFailedError:
click.secho('Table domains already exists', fg='green')
# Create index on domains.name
try:
r.table('domains').index_create('name').run(conn)
click.secho('Created index domains.name', fg='yellow')
except ReqlRuntimeError:
click.secho('Index domains.name already exists', fg='green')
开发者ID:NicolasLM,项目名称:crawler,代码行数:30,代码来源:cli.py
示例6: table_create
def table_create(connection):
for table in TABLE_NAMES:
try:
r.table_create(table).run(connection)
print ('Table ' + table + ' created')
except RqlRuntimeError:
print ('Table ' + table + ' already exists')
开发者ID:puhlenbruck,项目名称:CPPA,代码行数:7,代码来源:dbcontrols.py
示例7: _create
def _create(self):
try:
rdb.table_create(self.Meta.table_name).run()
except RqlRuntimeError:
return False
else:
return True
开发者ID:grieve,项目名称:fluzz,代码行数:7,代码来源:orm.py
示例8: setUp
def setUp(self):
self.db_name = 'radiowcs_test'
assert self.db_name != 'radiowcs'
self.table_name = 'test'
self.db = database.Database()
self.db.database_name = self.db_name
self.db.table_name = self.table_name
self.db.connect()
self.connection = r.connect(
host='localhost',
port=28015,
db=self.db_name,
auth_key='',
timeout=30
)
try:
r.db_create(self.db_name).run(self.connection)
r.table_create(self.table_name).run(self.connection)
except r.RqlRuntimeError:
print 'unittest setup: Drop table'
r.table_drop(self.table_name).run(self.connection)
r.table_create(self.table_name).run(self.connection)
r.db(self.db_name).table(self.table_name).index_create( 'title').run(self.connection)
r.db(self.db_name).table(self.table_name).index_create('artist').run(self.connection)
r.db(self.db_name).table(self.table_name).index_create( 'date').run(self.connection)
# 'out of order' insertions
r.db(self.db_name).table(self.table_name).insert({'title':'foobar', 'artist': 'Selena', 'date': '1430183323'}).run(self.connection)
r.db(self.db_name).table(self.table_name).insert({'title':'hello world', 'artist': 'John', 'date': '1430082566'}).run(self.connection)
r.db(self.db_name).table(self.table_name).insert({'title':'zombie apoc', 'artist': 'xxJANExx', 'date': '1430385845'}).run(self.connection)
r.db(self.db_name).table(self.table_name).insert({'title':'Black', 'artist': 'Kettle', 'date': '1430284300'}).run(self.connection)
开发者ID:TripleDogDare,项目名称:RadioWCSpy,代码行数:34,代码来源:test_db_rethink.py
示例9: _create_table
def _create_table(table_name):
logger.info("Creating {} table...".format(table_name))
with get_connection() as conn:
try:
r.table_create(table_name).run(conn)
logger.info("Created table {} successfully.".format(table_name))
except:
logger.info("Failed to create table {}!".format(table_name))
开发者ID:chuckSMASH,项目名称:know-it-all,代码行数:8,代码来源:tasks.py
示例10: ensure_table_exists
def ensure_table_exists(table_name, *args, **kwargs):
"""Creates a table if it doesn't exist."""
try:
r.table_create(table_name, *args, **kwargs).run(r_conn())
print 'Successfully created table ' + table_name
except r.RqlRuntimeError:
print 'Table ' + table_name + ' has already been created.'
pass # Ignore table already created
开发者ID:andyzg,项目名称:journal,代码行数:8,代码来源:db.py
示例11: create_db
def create_db():
tables = ['datasets', 'visualizations']
for table in tables:
try:
r.table_create(table).run(db.conn)
except RqlRuntimeError:
print 'Table `%s` already exists' % table
print 'Tables have been created.'
开发者ID:linkyndy,项目名称:krunchr,代码行数:8,代码来源:manage.py
示例12: make_table
def make_table(self):
try:
if self.async:
yield r.table_create(self.table).run(self.conn)
else:
r.table_create(self.table).run(self.conn)
log.info("Table %s created successfully." % self.table)
except r.RqlRuntimeError:
log.info("Table %s already exists... skipping." % self.table)
开发者ID:iepathos,项目名称:lol_tornado_betting,代码行数:9,代码来源:services.py
示例13: create_table
def create_table(conn):
try:
r.table_create("wallpapers").run(conn)
created = True
except r.errors.RqlRuntimeError:
#Already exists
created = False
pass
return created
开发者ID:phowat,项目名称:uowm,代码行数:9,代码来源:uowmcollector.py
示例14: generate_canary
def generate_canary():
""" Generates new canary string """
canary = ''.join(random.SystemRandom().choice('abcdef' + string.digits) for _ in range(64))
if 'canary' not in r.table_list().run(flask.g.rdb_conn):
r.table_create('canary').run(flask.g.rdb_conn)
r.table('canary').insert({'date': r.now(), 'canary': canary}).run(flask.g.rdb_conn)
return flask.jsonify(canary=canary)
开发者ID:PatrikHudak,项目名称:sqli_analysis,代码行数:9,代码来源:web.py
示例15: new_table
def new_table(self, name):
try:
r.table_create(name, primary_key='name').run(self.connection)
self.table = name
except RqlRuntimeError:
print 'Error: Table with name \"' + name + '\" already exists'
return False
return True
开发者ID:kwoner61,项目名称:money-app-code,代码行数:9,代码来源:Excom.py
示例16: configure
def configure(self):
"""Creates required database and tables/collections"""
self.connect()
try:
r.db_create(self.connection.db).run(self.connection)
r.table_create(self.table_name).run(self.connection)
r.table(self.table_name).index_create('date')
print 'Database setup completed.'
except r.RqlRuntimeError:
print 'App database already exists..'
开发者ID:TripleDogDare,项目名称:RadioWCSpy,代码行数:10,代码来源:db_rethink.py
示例17: post_stat
def post_stat(self, statDict):
if not self.config['enable_stats']:
return
LOG.debug("Posting stat: {0}".format(statDict['type']))
statTable = self.config['rethink_stat_table_template'].format(type=statDict['type'])
if statTable not in rethinkdb.table_list().run(self.rethink):
rethinkdb.table_create(statTable).run(self.rethink)
rethinkdb.table(statTable).insert(statDict).run(self.rethink)
开发者ID:moonbot,项目名称:shotgun-cache-server,代码行数:10,代码来源:controller.py
示例18: init_table
def init_table(name, **kwargs):
"""
Initialize a table in the database.
"""
with connect() as con:
try:
r.table_drop(name).run(con)
except r.ReqlOpFailedError:
pass
r.table_create(name, **kwargs).run(con)
开发者ID:starcraftman,项目名称:new-awesome,代码行数:10,代码来源:common.py
示例19: init
def init(self):
current_version = self.current_version()
if current_version is not None:
raise AlreadyInitializedException()
rethinkdb.table_create(MARKER_TABLE_NAME).run(self.conn)
rethinkdb.table(MARKER_TABLE_NAME).insert({
'version': 0,
'date_updated': utc_now(),
}).run(self.conn)
开发者ID:TombProject,项目名称:tomb_migrate,代码行数:11,代码来源:utils.py
示例20: dbcreate
def dbcreate(options):
"""Create pasahero database and tables"""
conn = r.connect(options.dbhost, options.dbport)
if options.dbname in r.db_list().run(conn):
return
r.db_create(options.dbname).run(conn)
conn.use(options.dbname)
r.table_create('users').run(conn)
r.table_create('migrations', primary_key='name').run(conn)
开发者ID:kyleddude007,项目名称:pasaHero,代码行数:12,代码来源:pavement.py
注:本文中的rethinkdb.table_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论