Example #1
0
def _makeSqlite(parsed):
    from norm.sqlite import sqlite
    connstr = mkConnStr(parsed)
    db = sqlite.connect(connstr)
    db.row_factory = sqlite.Row
    runner = BlockingRunner(db)
    runner.db_scheme = 'sqlite'
    return defer.succeed(runner)
Example #2
0
 def t(i, expected):
     expected_parts = expected.split(' ')
     parsed = parseURI(i)
     output = mkConnStr(parsed)
     parts = output.split(' ')
     self.assertEqual(set(expected_parts), set(parts),
                      "Expected URI\n    %r\nto become like conn "
                      "string\n    %r\nbut it was\n    %r" % (i,
                      expected, output))
Example #3
0
def _makeBlockingPostgres(parsed, connections=1):    
    import psycopg2
    from psycopg2.extras import DictCursor
    connstr = mkConnStr(parsed)
    pool = ConnectionPool()
    pool.db_scheme = 'postgres'
    for i in xrange(connections):
        db = psycopg2.connect(connstr, cursor_factory=DictCursor)
        runner = PostgresRunner(db)
        pool.add(runner)
    return defer.succeed(pool)
Example #4
0
def _makeTxPostgres(parsed, connections=1):
    from norm.tx_postgres import DictConnection
    pool = ConnectionPool()
    pool.db_scheme = 'postgres'
    connstr = mkConnStr(parsed)

    dlist = []
    for i in xrange(connections):
        conn = DictConnection()
        d = conn.connect(connstr)
        d.addCallback(lambda _: pool.add(conn))
        dlist.append(d)
    ret = defer.gatherResults(dlist)
    return ret.addCallback(lambda _: pool)
Example #5
0
File: util.py Project: iffy/norm
def postgresConnStr():
    if not postgres_url:
        raise SkipTest(skip_postgres)
    return mkConnStr(parseURI(postgres_url))
Example #6
0
 def t(self, i, expected):
     parsed = parseURI(i)
     output = mkConnStr(parsed)
     self.assertEqual(output, expected, "Expected URI %r to become conn "
                      "string\n%r\nbut it was\n%r" % (i, expected, output))