Here are the examples of the python api sqlalchemy.func.insert_foo taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
View Complete Implementation : test_deprecations.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
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))
astert 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())
astert conn2.execute(select([foo.c.data])).fetchall() == [
("data1",),
("data2",),
]
conn1.close()
conn2.close()
3
View Complete Implementation : test_transaction.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
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")]))
astert conn2.execute(select([foo.c.data])).fetchall() == []
conn1.execute(text("select insert_foo('moredata')"))
astert conn2.execute(select([foo.c.data])).fetchall() == []
trans = conn1.begin()
trans.commit()
astert conn2.execute(select([foo.c.data])).fetchall() == [
("data1",),
("moredata",),
]
conn1.close()
conn2.close()
3
View Complete Implementation : test_transaction.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_explicit_compiled(self):
conn1 = testing.db.connect()
conn2 = testing.db.connect()
conn1.execute(
select([func.insert_foo("data1")]).execution_options(
autocommit=True
)
)
astert conn2.execute(select([foo.c.data])).fetchall() == [("data1",)]
conn1.close()
conn2.close()
0
View Complete Implementation : test_transaction.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
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()