@@ -103,6 +103,11 @@ class DatabaseWrapper(BaseDatabaseWrapper):
103103
104104 @property
105105 def instance (self ):
106+ """Reference to a Cloud Spanner Instance containing the Database.
107+
108+ :rtype: :class:`~google.cloud.spanner_v1.instance.Instance`
109+ :returns: A new instance owned by the existing Spanner Client.
110+ """
106111 return spanner .Client ().instance (self .settings_dict ["INSTANCE" ])
107112
108113 @property
@@ -112,6 +117,12 @@ def _nodb_connection(self):
112117 )
113118
114119 def get_connection_params (self ):
120+ """Retrieve the connection parameters.
121+
122+ :rtype: dict
123+ :returns: A dictionary containing the Spanner connection parameters
124+ in Django Spanner format.
125+ """
115126 return {
116127 "project" : self .settings_dict ["PROJECT" ],
117128 "instance_id" : self .settings_dict ["INSTANCE" ],
@@ -120,20 +131,52 @@ def get_connection_params(self):
120131 ** self .settings_dict ["OPTIONS" ],
121132 }
122133
123- def get_new_connection (self , conn_params ):
134+ def get_new_connection (self , ** conn_params ):
135+ """Create a new connection with corresponding connection parameters.
136+
137+ :type conn_params: list
138+ :param conn_params: A List of the connection parameters for
139+ :class:`~google.cloud.spanner_dbapi.connection.Connection`
140+
141+ :rtype: :class:`google.cloud.spanner_dbapi.connection.Connection`
142+ :returns: A new Spanner DB API Connection object associated with the
143+ given Google Cloud Spanner resource.
144+
145+ :raises: :class:`ValueError` in case the given instance/database
146+ doesn't exist.
147+ """
124148 return Database .connect (** conn_params )
125149
126150 def init_connection_state (self ):
151+ """Initialize the state of the existing connection."""
127152 pass
128153
129154 def create_cursor (self , name = None ):
155+ """Create a new Database cursor.
156+
157+ :type name: str
158+ :param name: Currently not used.
159+
160+ :rtype: :class:`~google.cloud.spanner_dbapi.cursor.Cursor`
161+ :returns: The Cursor for this connection.
162+ """
130163 return self .connection .cursor ()
131164
132165 def _set_autocommit (self , autocommit ):
166+ """Set the Spanner transaction autocommit flag.
167+
168+ :type autocommit: bool
169+ :param autocommit: The new value of the autocommit flag.
170+ """
133171 with self .wrap_database_errors :
134172 self .connection .autocommit = autocommit
135173
136174 def is_usable (self ):
175+ """Check whether the connection is valid.
176+
177+ :rtype: bool
178+ :returns: True if the connection is open, otherwise False.
179+ """
137180 if self .connection is None :
138181 return False
139182 try :
0 commit comments