Esempio n. 1
0
        def aiotest():
            from aiorm import registry

            driver = yield from registry.connect("protocol://host/db", name="other")
            self.assertEqual(DummyDriver.last_url, "protocol://host/db")
            self.assertEqual(driver.database, "db")
            self.assertEqual(registry.get_driver("other"), driver)
            registry._drivers.pop("other")
            DummyDriver.last_url = None
Esempio n. 2
0
        def aiotest():
            from aiorm import registry

            driver = yield from registry.connect('protocol://host/db',
                                                 name='other')
            self.assertEqual(DummyDriver.last_url, 'protocol://host/db')
            self.assertEqual(driver.database, 'db')
            self.assertEqual(registry.get_driver('other'), driver)
            registry._drivers.pop('other')
            DummyDriver.last_url = None
Esempio n. 3
0
    def run(self, cursor=None):
        @asyncio.coroutine
        def wrapped(cursor):
            sql_statement = self.render_sql()
            log.debug('{!r} % {!r}'.format(*sql_statement))
            yield from cursor.execute(*sql_statement)
            return True

        if cursor:
            return (yield from wrapped(cursor))
        else:
            driver = registry.get_driver(self._args[0].__meta__['database'])
            with (yield from driver.cursor()) as cursor:
                return (yield from wrapped(cursor))
Esempio n. 4
0
    def run(self, cursor=None):
        @asyncio.coroutine
        def wrapped(cursor):
            sql_statement = self.render_sql()
            log.debug('{!r} % {!r}'.format(*sql_statement))
            yield from cursor.execute(*sql_statement)
            return True

        if cursor:
            return (yield from wrapped(cursor))
        else:
            driver = registry.get_driver(self._args[0].__meta__['database'])
            with (yield from driver.cursor()) as cursor:
                return (yield from wrapped(cursor))
Esempio n. 5
0
    def run(self, cursor=None, fetchall=True):
        @asyncio.coroutine
        def wrapped(cursor):
            sql_statement = self.render_sql()
            if log.isEnabledFor(logging.DEBUG):
                log.debug('{} % {!r}'.format(*sql_statement))
            yield from cursor.execute(*sql_statement)
            return ((yield from cursor.fetchall()) if fetchall else
                    (yield from cursor.fetchone()))

        if cursor:
            return (yield from wrapped(cursor))
        else:
            driver = registry.get_driver(self._args[0].__meta__['database'])
            with (yield from driver.cursor()) as cursor:
                return (yield from wrapped(cursor))
Esempio n. 6
0
    def run(self, cursor=None, fetchall=True):

        @asyncio.coroutine
        def wrapped(cursor):
            sql_statement = self.render_sql()
            if log.isEnabledFor(logging.DEBUG):
                log.debug('{} % {!r}'.format(*sql_statement))
            yield from cursor.execute(*sql_statement)
            return ((yield from cursor.fetchall())
                    if fetchall else (yield from cursor.fetchone()))

        if cursor:
            return (yield from wrapped(cursor))
        else:
            driver = registry.get_driver(self._args[0].__meta__['database'])
            with (yield from driver.cursor()) as cursor:
                return (yield from wrapped(cursor))
Esempio n. 7
0
 def __init__(self, database):
     self.driver = registry.get_driver(database)
     self.connection = None
     self.cursor = None
Esempio n. 8
0
 def __init__(self, database):
     self.driver = registry.get_driver(database)
     self.connection = None
     self.cursor = None