当前位置: 首页>>代码示例>>Python>>正文


Python rethinkdb.connect方法代码示例

本文整理汇总了Python中rethinkdb.connect方法的典型用法代码示例。如果您正苦于以下问题:Python rethinkdb.connect方法的具体用法?Python rethinkdb.connect怎么用?Python rethinkdb.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rethinkdb的用法示例。


在下文中一共展示了rethinkdb.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_args

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def parse_args(args):
    parser = argparse.ArgumentParser()
    parser.add_argument('--host',
                        help='The host for the api to run on.')
    parser.add_argument('--port',
                        help='The port for the api to run on.')
    parser.add_argument('--timeout',
                        help='Seconds to wait for a validator response')
    parser.add_argument('--validator',
                        help='The url to connect to a running validator')
    parser.add_argument('--db-host',
                        help='The host for the state database')
    parser.add_argument('--db-port',
                        help='The port for the state database')
    parser.add_argument('--db-name',
                        help='The name of the database')
    parser.add_argument('--debug',
                        help='Option to run Sanic in debug mode')
    parser.add_argument('--secret_key',
                        help='The API secret key')
    parser.add_argument('--aes-key',
                        help='The AES key used for private key encryption')
    parser.add_argument('--batcher-private-key',
                        help='The sawtooth key used for transaction signing')
    return parser.parse_args(args) 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:27,代码来源:main.py

示例2: setUp

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def setUp(self):
        try:
            g.rdb_conn = r.connect(
                host=app.config['DBHOST'], port=app.config['DBPORT'],
                auth_key=app.config['DBAUTHKEY'], db=app.config['DATABASE'])

            userdata = {
                'username': 'test@tester.com',
                'email': 'test@tester.com',
                'password': 'password456',
                'company': 'company',
                'contact': 'tester'
            }

            # Create test user
            user = User()
            user.config = app.config
            user.createUser(userdata, g.rdb_conn)

        except RqlDriverError:
            # If no connection possible throw 503 error
            abort(503, "No Database Connection Could be Established.") 
开发者ID:Runbook,项目名称:runbook,代码行数:24,代码来源:base.py

示例3: connect

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def connect(self):
        try:
            if self.config['rethink_authkey']:
                self.conn = r.connect(
                    host=self.config['rethink_host'], port=self.config['rethink_port'],
                    auth_key=self.config['rethink_authkey'], db=self.config['rethink_db']).repl()
            else:
                self.conn = r.connect(
                    host=self.config['rethink_host'], port=self.config['rethink_port'],
                    db=self.config['rethink_db']).repl()
                print "Connecting to RethinkDB"
            return self.conn
        except RqlDriverError:
            #This is acceptable at the moment since that's the normal behavior for every management script
            print "Cannot connect to rethinkdb, shutting down"
            sys.exit(1) 
开发者ID:Runbook,项目名称:runbook,代码行数:18,代码来源:runbookdb.py

示例4: start

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def start(self, scheduler, alias):
        super(RethinkDBJobStore, self).start(scheduler, alias)

        if self.client:
            self.conn = maybe_ref(self.client)
        else:
            self.conn = r.connect(db=self.database, **self.connect_args)

        if self.database not in r.db_list().run(self.conn):
            r.db_create(self.database).run(self.conn)

        if self.table not in r.table_list().run(self.conn):
            r.table_create(self.table).run(self.conn)

        if 'next_run_time' not in r.table(self.table).index_list().run(self.conn):
            r.table(self.table).index_create('next_run_time').run(self.conn)

        self.table = r.db(self.database).table(self.table) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:20,代码来源:rethinkdb.py

示例5: __init__

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def __init__(self, db, table_name=None, connection=None, host=None, port=None, user=None, password=None,
                 timeout=0.3):
        if not r:
            raise ImproperlyConfigured('You need to install the rethinkdb library to use the RethinkDB backend.')
        if connection:
            self.connection = connection
        elif host and port:
            if user and password:
                self.connection = r.connect(host=host, port=port, db=db, user=user, password=password, timeout=timeout)
            else:
                self.connection = r.connect(host=host, port=port, db=db, timeout=timeout)
        self.db = db
        self.table_name = table_name
        if self.connection is None:
            self.connection = r.connect(db=db, timeout=timeout)
        self._create_database() 
开发者ID:APSL,项目名称:kaneda,代码行数:18,代码来源:rethink.py

示例6: connect_rethink

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def connect_rethink(self, db, rethink_host='localhost', auth_key=None, **kwargs):
        '''
        Connect to rethink database,
        '''
        if rethink_host == 'localhost':
            try:
                conn = r.connect(host=rethink_host, port=28015, db=db).repl()
                print("Connected to the \"" + db + "\" database")
                return conn
            except:
                raise Exception("Failed to connect to the database, " + db)
        else:
            try:
                conn = r.connect(host=rethink_host, port=28015, db=db, auth_key=auth_key).repl()
                print("Connected to the \"" + db + "\" database")
                return conn
            except:
                raise Exception("Failed to connect to the database, " + db) 
开发者ID:nextstrain,项目名称:fauna,代码行数:20,代码来源:rethink_io.py

示例7: setup

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def setup(self):
        self.conn = rt.connect(self.host, self.port)
        # rt.db(self.db_name).table_drop(self.TABLE_NAME).run(self.conn)
        self.create_table() 
开发者ID:smartsdk,项目名称:ngsi-timeseries-api,代码行数:6,代码来源:rethink.py

示例8: _run_rethinkdb_action

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def _run_rethinkdb_action(self, action):

        # try to connect
        try:

            conn = r.connect(host=self.host, port=self.port, db=self.database, auth_key=self.auth_key)

        except Exception, e:

            log_to_postgres('Connection Falure:  %s' % e, ERROR)


        # Now try to run the action: 
开发者ID:rotten,项目名称:rethinkdb-multicorn-postgresql-fdw,代码行数:15,代码来源:rethinkdb_fdw.py

示例9: connect

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def connect(self):
        """Initializes a connection to the database
        """
        LOGGER.debug('Connecting to database: %s:%s', self._host, self._port)
        self._conn = r.connect(host=self._host, port=self._port) 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:7,代码来源:database.py

示例10: open_connections

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def open_connections(app):
    LOGGER.warning('opening database connection')
    r.set_loop_type('asyncio')
    app.config.DB_CONN = await r.connect(
        host=app.config.DB_HOST,
        port=app.config.DB_PORT,
        db=app.config.DB_NAME)

    app.config.VAL_CONN = Connection(app.config.VALIDATOR_URL)

    LOGGER.warning('opening validator connection')
    app.config.VAL_CONN.open() 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:14,代码来源:main.py

示例11: _create_connection

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def _create_connection(self):
        return rdb.connect(host=self._db_host, port=self._db_port,
                           db=_DF_DATABASE) 
开发者ID:openstack,项目名称:dragonflow,代码行数:5,代码来源:rethink_db_driver.py

示例12: before_request

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def before_request():
    '''
    This function establishes a connection
    to the rethinkDB before each connection
    '''
    try:
        g.rdb_conn = r.connect(
            host=app.config['DBHOST'], port=app.config['DBPORT'],
            auth_key=app.config['DBAUTHKEY'], db=app.config['DATABASE'])
    except RqlDriverError:                      # pragma: no cover
        # If no connection possible throw 503 error
        abort(503, "No Database Connection \
                    Could be Established.")     # pragma: no cover 
开发者ID:Runbook,项目名称:runbook,代码行数:15,代码来源:views.py

示例13: tearDown

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def tearDown(self):
        # why the need to reconnect?
        g.rdb_conn = r.connect(
            host=app.config['DBHOST'], port=app.config['DBPORT'],
            auth_key=app.config['DBAUTHKEY'], db=app.config['DATABASE'])
        r.db('crdb').table('users').delete().run(g.rdb_conn)
        try:
            g.rdb_conn.close()
        except AttributeError:
            # Who cares?
            pass 
开发者ID:Runbook,项目名称:runbook,代码行数:13,代码来源:base.py

示例14: check_server_up

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def check_server_up(self):
        """Test connection to the server."""
        log.info("Connecting to RethinkDB at {0}:{1}".format(
            self.hostname, self.port))

        if not self.hostname:
            return False

        try:
            self.conn = rethinkdb.connect(host=self.hostname,
                                          port=self.port, db='test')
            return True
        except rethinkdb.RqlDriverError as err:
            log.warning(err)
        return False 
开发者ID:man-group,项目名称:pytest-plugins,代码行数:17,代码来源:rethink.py

示例15: rethink_backend_connection

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import connect [as 别名]
def rethink_backend_connection(rethink_settings):
    connection = r.connect(host=rethink_settings.RETHINK_HOST, port=rethink_settings.RETHINK_PORT,
                           db=rethink_settings.RETHINK_DB, timeout=rethink_settings.RETHINK_TIMEOUT)
    return RethinkBackend(db=rethink_settings.RETHINK_DB, connection=connection) 
开发者ID:APSL,项目名称:kaneda,代码行数:6,代码来源:conftest.py


注:本文中的rethinkdb.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。