| 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() |