Example #1
0
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.execute").active = True
    # journal.debug("postgres.connection").active = True
    journal.debug("postgres.transactions").active = True

    # this is the SQL statement that looks for a table by a given name
    sql = "SELECT tablename FROM pg_tables WHERE tablename='{}'".format(Weather.pyre_name)

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.postgres(name="test").attach()

    # in a transaction block
    with db:
        # create the table
        db.createTable(Weather)
        # verify it is there
        assert db.execute(sql) == (('tablename',), ('weather',))
        # drop the table
        db.dropTable(Weather)
        # verify it is not there
        assert db.execute(sql) == (('tablename',),)

    # and return the connection and the table
    return db, Weather
Example #2
0
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.execute").active = True
    # journal.debug("postgres.connection").active = True
    journal.debug("postgres.transactions").active = True

    # this is the SQL statement that looks for a table by a given name
    sql = "SELECT tablename FROM pg_tables WHERE tablename='{}'".format(
        Weather.pyre_name)

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.postgres(name="test").attach()

    # in a transaction block
    with db:
        # create the table
        db.createTable(Weather)
        # verify it is there
        assert db.execute(sql) == (('tablename', ), ('weather', ))
        # drop the table
        db.dropTable(Weather)
        # verify it is not there
        assert db.execute(sql) == (('tablename', ), )

    # and return the connection and the table
    return db, Weather
Example #3
0
def test():
    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.sqlite(name="test").attach()

    # in a transaction block
    with db:
        # create the location table
        db.createTable(Location)
        # create the weather table
        db.createTable(Weather)

        # drop the weather table
        db.dropTable(Weather)
        # drop the location table
        db.dropTable(Location)

    # and return the connection and the tables
    return db, Weather, Location
Example #4
0
def test():
    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.sqlite(name="test").attach()

    # in a transaction block
    with db:
        # create the location table
        db.createTable(Location)
        # create the weather table
        db.createTable(Weather)

        # drop the weather table
        db.dropTable(Weather)
        # drop the location table
        db.dropTable(Location)

    # and return the connection and the tables
    return db, Weather, Location
Example #5
0
def test():
    # this is the SQL statement that looks for a table by a given name
    sql = "SELECT * FROM weather"

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.sqlite(name="test").attach()

    # in a transaction block
    with db:
        # create the table
        db.createTable(Weather)
        # verify it is there
        assert tuple(db.execute(sql)) == ()
        # drop the table
        db.dropTable(Weather)

    # and return the connection and the table
    return db, Weather
Example #6
0
def test():
    # this is the SQL statement that looks for a table by a given name
    sql = "SELECT * FROM weather"

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.sqlite(name="test").attach()

    # in a transaction block
    with db:
        # create the table
        db.createTable(Weather)
        # verify it is there
        assert tuple(db.execute(sql)) == ()
        # drop the table
        db.dropTable(Weather)

    # and return the connection and the table
    return db, Weather
Example #7
0
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.execute").active = True
    # journal.debug("postgres.connection").active = True
    journal.debug("postgres.transactions").active = True

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.postgres(name="test").attach()

    # ask {libpq}  to be quiet
    db.execute("SET client_min_messages = warning;")
    # in a transaction block
    with db:
        # create the location table
        db.createTable(Location)
        # verify it is there
        assert queryForTable(db, Location) == (('tablename', ),
                                               (Location.pyre_name, ))

        # create the weather table
        # print('\n'.join(db.sql.createTable(Weather)))
        db.createTable(Weather)
        # verify it is there
        assert queryForTable(db, Weather) == (('tablename', ),
                                              (Weather.pyre_name, ))

        # drop the weather table
        db.dropTable(Weather)
        # and check it's gone
        assert queryForTable(db, Weather) == (('tablename', ), )

        # drop the location table
        # print('\n'.join(db.sql.createTable(Location)))
        db.dropTable(Location)
        # and check it's gone too
        assert queryForTable(db, Location) == (('tablename', ), )

    # and return the connection and the tables
    return db, Weather, Location
def test():
    import journal
    # journal.debug("postgres.init").active = True
    # journal.debug("postgres.execute").active = True
    # journal.debug("postgres.connection").active = True
    journal.debug("postgres.transactions").active = True

    # build a database component and connect to the database specified in the local
    # configuration file
    db = pyre.db.postgres(name="test").attach()

    # ask {libpq}  to be quiet
    db.execute("SET client_min_messages = warning;")
    # in a transaction block
    with db:
        # create the location table
        db.createTable(Location)
        # verify it is there
        assert queryForTable(db, Location) == (('tablename',), (Location.pyre_name,))

        # create the weather table
        # print('\n'.join(db.sql.createTable(Weather)))
        db.createTable(Weather)
        # verify it is there
        assert queryForTable(db, Weather) == (('tablename',), (Weather.pyre_name,))

        # drop the weather table
        db.dropTable(Weather)
        # and check it's gone
        assert queryForTable(db, Weather) == (('tablename',),)

        # drop the location table
        # print('\n'.join(db.sql.createTable(Location)))
        db.dropTable(Location)
        # and check it's gone too
        assert queryForTable(db, Location) == (('tablename',),)

    # and return the connection and the tables
    return db, Weather, Location