File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -251,15 +251,19 @@ There are a few coding conventions we use in beets:
251
251
To fetch Item objects from the database, use lib.items(…) and supply
252
252
a query as an argument. Resist the urge to write raw SQL for your
253
253
query. If you must use lower-level queries into the database, do
254
- this:
254
+ this, for example :
255
255
256
256
.. code-block :: python
257
257
258
258
with lib.transaction() as tx:
259
- rows = tx.query(" SELECT … " )
259
+ rows = tx.query(" SELECT path FROM items WHERE album_id = ? " , (album_id,) )
260
260
261
261
Transaction objects help control concurrent access to the database
262
262
and assist in debugging conflicting accesses.
263
+
264
+ Make sure that variables are passed to the query as a tuple to prevent SQL
265
+ injection attacks.
266
+
263
267
- f-strings should be used instead of the ``% `` operator and ``str.format() ``
264
268
calls.
265
269
- Never ``print `` informational messages; use the
You can’t perform that action at this time.
0 commit comments