Skip to content

Commit d662511

Browse files
committed
Name the params for simple API; #4
1 parent 2407393 commit d662511

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

postgres.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,29 @@ def __init__(self, url, minconn=1, maxconn=10):
179179
, connection_factory=Connection
180180
)
181181

182-
def execute(self, *a, **kw):
182+
def execute(self, sql, parameters=None):
183183
"""Execute the query and discard any results.
184+
185+
:param unicode sql: the SQL statement to execute
186+
:param parameters: the bind parameters for the SQL statement
187+
:type parameters: tuple or dict
188+
184189
"""
185190
with self.get_cursor() as cursor:
186-
cursor.execute(*a, **kw)
191+
cursor.execute(sql, parameters)
187192

188-
def fetchone(self, *a, **kw):
193+
def fetchone(self, sql, parameters=None):
189194
"""Execute the query and return a single result (``dict`` or ``None``).
190195
"""
191196
with self.get_cursor() as cursor:
192-
cursor.execute(*a, **kw)
197+
cursor.execute(sql, parameters)
193198
return cursor.fetchone()
194199

195-
def fetchall(self, *a, **kw):
200+
def fetchall(self, sql, parameters=None):
196201
"""Execute the query and yield the results (``dict``).
197202
"""
198203
with self.get_cursor() as cursor:
199-
cursor.execute(*a, **kw)
204+
cursor.execute(sql, parameters)
200205
for row in cursor:
201206
yield row
202207

0 commit comments

Comments
 (0)