MCPcopy
hub / github.com/psycopg/psycopg / test_execute

Method test_execute

tests/test_sql.py:171–188  ·  view source on GitHub ↗
(self, conn)

Source from the content-addressed store, hash-verified

169 assert s.as_string(conn) == "select 'he''lo', 10, '2020-01-01'::date"
170
171 def test_execute(self, conn):
172 cur = conn.cursor()
173 cur.execute("""
174 create table test_compose (
175 id serial primary key,
176 foo text, bar text, "ba'z" text)
177 """)
178 cur.execute(
179 sql.SQL("insert into {0} (id, {1}) values (%s, {2})").format(
180 sql.Identifier("test_compose"),
181 sql.SQL(", ").join(map(sql.Identifier, ["foo", "bar", "ba'z"])),
182 (sql.Placeholder() * 3).join(", "),
183 ),
184 (10, "a", "b", "c"),
185 )
186
187 cur.execute("select * from test_compose")
188 assert cur.fetchall() == [(10, "a", "b", "c")]
189
190 def test_executemany(self, conn):
191 cur = conn.cursor()

Callers

nothing calls this directly

Calls 5

formatMethod · 0.80
cursorMethod · 0.45
executeMethod · 0.45
joinMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected