summaryrefslogtreecommitdiff
path: root/examples/encoding.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-12-03 18:47:19 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2017-12-10 10:51:07 -0800
commit9de46e416e5ac1be1c5ff170d1c1ada5b8d7278f (patch)
tree62291426bc36f26ed5ac65d597ed15a5654a4e22 /examples/encoding.py
parentef64493b8913e4069c4422ad14da6de405c445f6 (diff)
downloadpsycopg2-9de46e416e5ac1be1c5ff170d1c1ada5b8d7278f.tar.gz
Use print() function instead of print statement throughout project
Forward compatible with newer Pythons.
Diffstat (limited to 'examples/encoding.py')
-rw-r--r--examples/encoding.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/encoding.py b/examples/encoding.py
index 77fd871..693a88d 100644
--- a/examples/encoding.py
+++ b/examples/encoding.py
@@ -26,80 +26,80 @@ import psycopg2.extensions
if len(sys.argv) > 1:
DSN = sys.argv[1]
-print "Opening connection using dsn:", DSN
+print("Opening connection using dsn:", DSN)
conn = psycopg2.connect(DSN)
-print "Initial encoding for this connection is", conn.encoding
+print("Initial encoding for this connection is", conn.encoding)
-print "\n** This example is supposed to be run in a UNICODE terminal! **\n"
+print("\n** This example is supposed to be run in a UNICODE terminal! **\n")
-print "Available encodings:"
+print("Available encodings:")
encs = psycopg2.extensions.encodings.items()
encs.sort()
for a, b in encs:
- print " ", a, "<->", b
+ print(" ", a, "<->", b)
-print "Using STRING typecaster"
-print "Setting backend encoding to LATIN1 and executing queries:"
+print("Using STRING typecaster")
+print("Setting backend encoding to LATIN1 and executing queries:")
conn.set_client_encoding('LATIN1')
curs = conn.cursor()
curs.execute("SELECT %s::TEXT AS foo", ('àèìòù',))
x = curs.fetchone()[0]
-print " ->", unicode(x, 'latin-1').encode('utf-8'), type(x)
+print(" ->", unicode(x, 'latin-1').encode('utf-8'), type(x))
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", unicode(x, 'latin-1').encode('utf-8'), type(x)
+print(" ->", unicode(x, 'latin-1').encode('utf-8'), type(x))
-print "Setting backend encoding to UTF8 and executing queries:"
+print("Setting backend encoding to UTF8 and executing queries:")
conn.set_client_encoding('UNICODE')
curs = conn.cursor()
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù'.encode('utf-8'),))
x = curs.fetchone()[0]
-print " ->", x, type(x)
+print(" ->", x, type(x))
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", x, type(x)
+print(" ->", x, type(x))
-print "Using UNICODE typecaster"
+print("Using UNICODE typecaster")
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
-print "Setting backend encoding to LATIN1 and executing queries:"
+print("Setting backend encoding to LATIN1 and executing queries:")
conn.set_client_encoding('LATIN1')
curs = conn.cursor()
curs.execute("SELECT %s::TEXT AS foo", ('àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
-print "Setting backend encoding to UTF8 and executing queries:"
+print("Setting backend encoding to UTF8 and executing queries:")
conn.set_client_encoding('UNICODE')
curs = conn.cursor()
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù'.encode('utf-8'),))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
curs.execute("SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
-print "Executing full UNICODE queries"
+print("Executing full UNICODE queries")
-print "Setting backend encoding to LATIN1 and executing queries:"
+print("Setting backend encoding to LATIN1 and executing queries:")
conn.set_client_encoding('LATIN1')
curs = conn.cursor()
curs.execute(u"SELECT %s::TEXT AS foo", ('àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
curs.execute(u"SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
-print "Setting backend encoding to UTF8 and executing queries:"
+print("Setting backend encoding to UTF8 and executing queries:")
conn.set_client_encoding('UNICODE')
curs = conn.cursor()
curs.execute(u"SELECT %s::TEXT AS foo", (u'àèìòù'.encode('utf-8'),))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))
curs.execute(u"SELECT %s::TEXT AS foo", (u'àèìòù',))
x = curs.fetchone()[0]
-print " ->", x.encode('utf-8'), ":", type(x)
+print(" ->", x.encode('utf-8'), ":", type(x))