You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,40 @@ Enabling autocommit
86
86
con.run("VACUUM")
87
87
con.autocommit = False
88
88
89
+
90
+
Configuring cursor paramstyle
91
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92
+
The paramstyle for a cursor can be modified via ``cursor.paramstyle``. The default paramstyle used is ``format``. Valid values for ``paramstyle`` include ``qmark, numeric, named, format, pyformat``.
93
+
94
+
.. code-block:: python
95
+
96
+
# qmark
97
+
redshift_connector.paramstyle ='qmark'
98
+
sql ='insert into foo(bar, jar) VALUES(?, ?)'
99
+
cursor.execute(sql, (1, "hello world"))
100
+
101
+
# numeric
102
+
redshift_connector.paramstyle ='numeric'
103
+
sql ='insert into foo(bar, jar) VALUES(:1, :2)'
104
+
cursor.execute(sql, (1, "hello world"))
105
+
106
+
# named
107
+
redshift_connector.paramstyle ='numeric'
108
+
sql ='insert into foo(bar, jar) VALUES(:p1, :p2)'
109
+
cursor.execute(sql, p1=1, p2="hello world")
110
+
111
+
# format
112
+
redshift_connector.paramstyle ='format'
113
+
sql ='insert into foo(bar, jar) VALUES(%s, %s)'
114
+
cursor.execute(sql, (1, "hello world"))
115
+
116
+
# pyformat
117
+
redshift_connector.paramstyle ='pyformat'
118
+
sql ='insert into foo(bar, jar) VALUES(%(bar)s, %(jar)s)'
0 commit comments