Exemplo n.º 1
0
def test():
    from pyre.extensions import postgres as pyrepg
    # initialize the module exceptions
    import pyre.db.exceptions as exceptions
    pyrepg.registerExceptions(exceptions)

    # make a connection
    connection = pyrepg.connect("dbname=postgres")
    # execute a command
    try:
        pyrepg.execute(connection, "no-such-command")
        assert False
    except pyrepg.ProgrammingError:
        pass

    # and return it
    return connection
def test():
    from pyre.extensions import postgres as pyrepg
    # initialize the module exceptions
    import pyre.db.exceptions as exceptions
    pyrepg.registerExceptions(exceptions)

    # make a connection
    connection = pyrepg.connect("dbname=postgres")
    # execute a command
    try:
        pyrepg.execute(connection, "no-such-command")
        assert False
    except pyrepg.ProgrammingError:
        pass

    # and return it
    return connection
Exemplo n.º 3
0
def test():
    # import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.connection").active = True
    # journal.debug("postgres.execution").active = True

    from pyre.extensions import postgres as pyrepg
    # initialize the module exceptions
    import pyre.db.exceptions as exceptions
    pyrepg.registerExceptions(exceptions)

    # make a connection
    connection = pyrepg.connect("dbname=postgres")
    # execute a command
    command = "SELECT datname FROM pg_database WHERE datname='postgres'"
    result = pyrepg.execute(connection, command)
    # check that we got what we expected
    assert result == (('datname', ), ('postgres', ))

    # and return the connection and the resulting tuple
    return connection, result