diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index ef39fa9867..a1c858bd8f 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -146,9 +146,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
             if self._version[0:2] < (8, 0):
                 # No savepoint support for earlier version of PostgreSQL.
                 self.features.uses_savepoints = False
-        cursor.execute("SET client_encoding to 'UNICODE'")
-        cursor = UnicodeCursorWrapper(cursor, 'utf-8')
-        return cursor
+            cursor.execute("SET client_encoding to 'UNICODE'")
+        return UnicodeCursorWrapper(cursor, 'utf-8')
 
 def typecast_string(s):
     """