Skip to content

Commit

Permalink
Test both param styles with DB API 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Aug 27, 2023
1 parent 53e8f10 commit c2a4290
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ def test_percent_sign(self):
cur.execute("select 'a %% sign'")
self.assertEqual(cur.fetchone(), ('a % sign',))

def test_paramstyles(self):
self.assertEqual(pgdb.paramstyle, 'pyformat')
con = self._connect()
cur = con.cursor()
# parameters can be passed as tuple
cur.execute("select %s, %s, %s", (123, 'abc', True))
self.assertEqual(cur.fetchone(), (123, 'abc', True))
# parameters can be passed as dict
cur.execute("select %(one)s, %(two)s, %(one)s, %(three)s", {
"one": 123, "two": "abc", "three": True
})
self.assertEqual(cur.fetchone(), (123, 'abc', 123, True))

def test_callproc_no_params(self):
con = self._connect()
cur = con.cursor()
Expand Down

0 comments on commit c2a4290

Please sign in to comment.