Beispiel #1
0
    def test_explicit_connection(self):
        conn1 = testing.db.connect()
        conn2 = testing.db.connect()
        conn1.execution_options(autocommit=True).\
            execute(select([func.insert_foo('data1'
                )]))
        eq_(conn2.execute(select([foo.c.data])).fetchall(), [('data1', )])

        # connection supersedes statement

        conn1.execution_options(autocommit=False).\
            execute(select([func.insert_foo('data2'
                )]).execution_options(autocommit=True))
        eq_(conn2.execute(select([foo.c.data])).fetchall(), [('data1', )])

        # ditto

        conn1.execution_options(autocommit=True).\
            execute(select([func.insert_foo('data3'
                )]).execution_options(autocommit=False))
        eq_(
            conn2.execute(select([foo.c.data])).fetchall(), [('data1', ),
                                                             ('data2', ),
                                                             ('data3', )])
        conn1.close()
        conn2.close()
Beispiel #2
0
    def test_explicit_connection(self):
        conn1 = testing.db.connect()
        conn2 = testing.db.connect()
        conn1.execution_options(autocommit=True).\
            execute(select([func.insert_foo('data1'
                )]))
        eq_(conn2.execute(select([foo.c.data])).fetchall(), [('data1',
            )])

        # connection supercedes statement

        conn1.execution_options(autocommit=False).\
            execute(select([func.insert_foo('data2'
                )]).execution_options(autocommit=True))
        eq_(conn2.execute(select([foo.c.data])).fetchall(), [('data1',
            )])

        # ditto

        conn1.execution_options(autocommit=True).\
            execute(select([func.insert_foo('data3'
                )]).execution_options(autocommit=False))
        eq_(conn2.execute(select([foo.c.data])).fetchall(), [('data1',
            ), ('data2', ), ('data3', )])
        conn1.close()
        conn2.close()
 def test_explicit_compiled_deprecated(self):
     conn1 = testing.db.connect()
     conn2 = testing.db.connect()
     conn1.execute(select([func.insert_foo("data1")], autocommit=True))
     assert conn2.execute(select([foo.c.data])).fetchall() == [("data1",)]
     conn1.execute(select([func.insert_foo("data2")]).autocommit())
     assert conn2.execute(select([foo.c.data])).fetchall() == [("data1",), ("data2",)]
     conn1.close()
     conn2.close()
Beispiel #4
0
 def test_explicit_compiled_deprecated(self):
     conn1 = testing.db.connect()
     conn2 = testing.db.connect()
     conn1.execute(select([func.insert_foo('data1')], autocommit=True))
     assert conn2.execute(select([foo.c.data])).fetchall() \
         == [('data1', )]
     conn1.execute(select([func.insert_foo('data2')]).autocommit())
     assert conn2.execute(select([foo.c.data])).fetchall() \
         == [('data1', ), ('data2', )]
     conn1.close()
     conn2.close()
 def test_explicit_compiled(self):
     conn1 = testing.db.connect()
     conn2 = testing.db.connect()
     with testing.expect_deprecated(
             "The select.autocommit parameter is deprecated"):
         conn1.execute(select([func.insert_foo("data1")], autocommit=True))
     assert conn2.execute(select([foo.c.data])).fetchall() == [("data1", )]
     with testing.expect_deprecated(
             r"The SelectBase.autocommit\(\) method is deprecated,"):
         conn1.execute(select([func.insert_foo("data2")]).autocommit())
     assert conn2.execute(select([foo.c.data])).fetchall() == [
         ("data1", ),
         ("data2", ),
     ]
     conn1.close()
     conn2.close()
Beispiel #6
0
 def test_explicit_compiled(self):
     conn1 = testing.db.connect()
     conn2 = testing.db.connect()
     conn1.execute(select([func.insert_foo('data1'
                   )]).execution_options(autocommit=True))
     assert conn2.execute(select([foo.c.data])).fetchall() \
         == [('data1', )]
     conn1.close()
     conn2.close()
Beispiel #7
0
 def test_explicit_compiled(self):
     conn1 = testing.db.connect()
     conn2 = testing.db.connect()
     conn1.execute(
         select([func.insert_foo("data1")
                 ]).execution_options(autocommit=True))
     assert conn2.execute(select([foo.c.data])).fetchall() == [("data1", )]
     conn1.close()
     conn2.close()
    def test_control(self):

        # test that not using autocommit does not commit

        conn1 = testing.db.connect()
        conn2 = testing.db.connect()
        conn1.execute(select([func.insert_foo("data1")]))
        assert conn2.execute(select([foo.c.data])).fetchall() == []
        conn1.execute(text("select insert_foo('moredata')"))
        assert conn2.execute(select([foo.c.data])).fetchall() == []
        trans = conn1.begin()
        trans.commit()
        assert conn2.execute(select([foo.c.data])).fetchall() == [("data1",), ("moredata",)]
        conn1.close()
        conn2.close()
Beispiel #9
0
    def test_control(self):

        # test that not using autocommit does not commit

        conn1 = testing.db.connect()
        conn2 = testing.db.connect()
        conn1.execute(select([func.insert_foo('data1')]))
        assert conn2.execute(select([foo.c.data])).fetchall() == []
        conn1.execute(text("select insert_foo('moredata')"))
        assert conn2.execute(select([foo.c.data])).fetchall() == []
        trans = conn1.begin()
        trans.commit()
        assert conn2.execute(select([foo.c.data])).fetchall() \
            == [('data1', ), ('moredata', )]
        conn1.close()
        conn2.close()