Пример #1
0
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.connection").active = True
    # journal.debug("postgres.execution").active = True
    # journal.debug("postgres.conversions").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'"
    # submit it for asynchronous processing
    pyrepg.submit(connection, command)

    # loop until the entire result has been assembled
    while pyrepg.busy(connection):
        pyrepg.consume(connection)

    # retrieve it
    result = pyrepg.retrieve(connection)
    # check that we got what we expected
    assert result == (('datname',), ('postgres',))

    # call retrieve again; this time there should be nothing to get
    result = pyrepg.retrieve(connection)
    assert result == None

    # and return the connection and the resulting tuple
    return connection, result
Пример #2
0
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.connection").active = True
    # journal.debug("postgres.execution").active = True
    # journal.debug("postgres.conversions").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'"
    # submit it for asynchronous processing
    pyrepg.submit(connection, command)

    # loop until the entire result has been assembled
    while pyrepg.busy(connection):
        pyrepg.consume(connection)

    # retrieve it
    result = pyrepg.retrieve(connection)
    # check that we got what we expected
    assert result == (('datname', ), ('postgres', ))

    # call retrieve again; this time there should be nothing to get
    result = pyrepg.retrieve(connection)
    assert result == None

    # and return the connection and the resulting tuple
    return connection, result
Пример #3
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")
    # and return it
    return connection
Пример #4
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")
    # and return it
    return connection
Пример #5
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
Пример #7
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