Skip to content
Myr

Merge pull request #4302 from karintou8710/old-print

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes old print statement in signal and SQLite pages

authored by David Lord · committed by GitHub · parents c5ed6c5, 21def4e · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:docs/patterns/sqlite3.rst+3 added-3 removed
111 unmodified lines
112113Here is how you can use it::114115 for user in query_db('select * from users'):116 print user['username'], 'has the id', user['user_id']116 print(user['username'], 'has the id', user['user_id'])117118Or if you just want a single result::119120 user = query_db('select * from users where username = ?',121 [the_username], one=True)122 if user is None:123 print 'No such user'123 print('No such user')124 else:125 print the_username, 'has the id', user['user_id']125 print(the_username, 'has the id', user['user_id'])126127To pass variable parts to the SQL statement, use a question mark in the128statement and pass in the arguments as a list. Never directly add them to129the SQL statement with string formatting because this makes it possible
22 unmodified lines
modified:docs/signals.rst+1 added-1 removed
175 unmodified lines
176 from flask import template_rendered177178 @template_rendered.connect_via(app)179 def when_template_rendered(sender, template, context, **extra):180 print f'Template {template.name} is rendered with {context}'180 print(f'Template {template.name} is rendered with {context}')181182Core Signals183------------184
4 unmodified lines