@@ -126,41 +126,109 @@ def get_row_result(self, cmd, *args):
126
126
127
127
128
128
class BaseSession (object ):
129
+ """Base functionality for Session classes through the X Protocol.
130
+
131
+ This class encloses the core functionality to be made available on both
132
+ the XSession and NodeSession classes, such functionality includes:
133
+
134
+ - Accessing available schemas.
135
+ - Schema management operations.
136
+ - Enabling/disabling warning generation.
137
+ - Retrieval of connection information.
138
+
139
+ Args:
140
+ settings (dict): Connection data used to connect to the database.
141
+ """
129
142
def __init__ (self , settings ):
130
143
self ._settings = settings
131
144
self ._connection = Connection (self ._settings )
132
145
self ._connection .connect ()
133
146
134
147
def get_schema (self , name ):
148
+ """Retrieves a Schema object from the current session by it's name.
149
+
150
+ Args:
151
+ name (string): The name of the Schema object to be retrieved.
152
+
153
+ Returns:
154
+ mysqlx.Schema: The Schema object with the given name.
155
+ """
135
156
return Schema (self , name )
136
157
137
158
def drop_schema (self , name ):
159
+ """Drops the schema with the specified name.
160
+
161
+ Args:
162
+ name (string): The name of the Schema object to be retrieved.
163
+ """
138
164
self ._connection .execute_nonquery (
139
165
"sql" , _DROP_DATABASE_QUERY .format (name ), True )
140
166
141
167
def create_schema (self , name ):
168
+ """Creates a schema on the database and returns the corresponding
169
+ object.
170
+
171
+ Args:
172
+ name (string): A string value indicating the schema name.
173
+ """
142
174
self ._connection .execute_nonquery (
143
175
"sql" , _CREATE_DATABASE_QUERY .format (name ), True )
144
176
return Schema (self , name )
145
177
146
178
def start_transaction (self ):
179
+ """Starts a transaction context on the server.
180
+ """
147
181
self ._connection .execute_nonquery ("START TRANSACTION" )
148
182
149
183
def commit (self ):
184
+ """Commits all the operations executed after a call to
185
+ startTransaction().
186
+ """
150
187
self ._connection .execute_nonquery ("COMMIT" )
151
188
152
- def roillback (self ):
189
+ def rollback (self ):
190
+ """Discards all the operations executed after a call to
191
+ startTransaction().
192
+ """
153
193
self ._connection .execute_nonquery ("ROLLBACK" )
154
194
155
195
156
196
class XSession (BaseSession ):
197
+ """Enables interaction with an X Protocol enabled MySQL Product.
198
+
199
+ The functionality includes:
200
+
201
+ - Accessing available schemas.
202
+ - Schema management operations.
203
+ - Enabling/disabling warning generation.
204
+ - Retrieval of connection information.
205
+
206
+ Args:
207
+ settings (dict): Connection data used to connect to the database.
208
+ """
157
209
def __init__ (self , settings ):
158
210
super (XSession , self ).__init__ (settings )
159
211
160
212
161
213
class NodeSession (BaseSession ):
214
+ """Enables interaction with an X Protocol enabled MySQL Server.
215
+
216
+ The functionality includes:
217
+
218
+ - Accessing available schemas.
219
+ - Schema management operations.
220
+ - Enabling/disabling warning generation.
221
+ - Retrieval of connection information.
222
+ - Includes SQL Execution.
223
+
224
+ Args:
225
+ settings (dict): Connection data used to connect to the database.
226
+ """
162
227
def __init__ (self , settings ):
163
228
super (NodeSession , self ).__init__ (settings )
164
229
165
230
def sql (self , sql ):
231
+ """Creates a :class:`mysqlx.SqlStatement` object to allow running the
232
+ SQL statement on the target MySQL Server.
233
+ """
166
234
return SqlStatement (self ._connection , sql )
0 commit comments