Skip to content

Commit 97aa93e

Browse files
committed
Add missing docstrings and update CPYINT revision
1 parent ccf6cb1 commit 97aa93e

File tree

5 files changed

+98
-9
lines changed

5 files changed

+98
-9
lines changed

cpyint

lib/mysqlx/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
from .result import (ColumnMetaData, Row, Result, BufferingResult, RowResult,
3232
SqlResult, ColumnType)
3333
from .statement import (Statement, FilterableStatement, SqlStatement,
34-
AddStatement, RemoveStatement, ModifyStatement,
35-
SelectStatement, InsertStatement, DeleteStatement,
36-
UpdateStatement, CreateCollectionIndexStatement,
34+
FindStatement, AddStatement, RemoveStatement,
35+
ModifyStatement, SelectStatement, InsertStatement,
36+
DeleteStatement, UpdateStatement,
37+
CreateCollectionIndexStatement,
3738
DropCollectionIndexStatement)
3839
from .dbdoc import DbDoc
3940

@@ -76,11 +77,11 @@ def get_node_session(settings):
7677

7778
# mysqlx.result
7879
"ColumnMetaData", "Row", "Result", "BufferingResult", "RowResult",
79-
"SqlResult",
80+
"SqlResult", "ColumnType",
8081

8182
# mysqlx.statement
8283
"DbDoc", "Statement", "FilterableStatement", "SqlStatement",
83-
"AddStatement", "RemoveStatement", "ModifyStatement", "SelectStatement",
84-
"InsertStatement", "DeleteStatement", "UpdateStatement",
84+
"FindStatement", "AddStatement", "RemoveStatement", "ModifyStatement",
85+
"SelectStatement", "InsertStatement", "DeleteStatement", "UpdateStatement",
8586
"CreateCollectionIndexStatement", "DropCollectionIndexStatement",
8687
]

lib/mysqlx/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def rollback(self):
198198

199199

200200
class XSession(BaseSession):
201-
"""Enables interaction with an X Protocol enabled MySQL Product.
201+
"""Enables interaction with a X Protocol enabled MySQL Product.
202202
203203
The functionality includes:
204204
@@ -215,7 +215,7 @@ def __init__(self, settings):
215215

216216

217217
class NodeSession(BaseSession):
218-
"""Enables interaction with an X Protocol enabled MySQL Server.
218+
"""Enables interaction with a X Protocol enabled MySQL Server.
219219
220220
The functionality includes:
221221

lib/mysqlx/result.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ def Message(self):
519519

520520

521521
class Row(object):
522+
"""Represents a row element returned from a SELECT query.
523+
524+
Args:
525+
rs (mysqlx.Result): The Result set.
526+
fields (list): The list of fields.
527+
"""
522528
def __init__(self, rs, fields):
523529
self._fields = fields
524530
self._resultset = rs
@@ -531,6 +537,11 @@ def __getitem__(self, index):
531537
return self._fields[index]
532538

533539
def get_string(self, str_index):
540+
"""Returns the value if the index by string.
541+
542+
Args:
543+
str_index (str): The string index.
544+
"""
534545
int_index = self._resultset.index_of(str_index)
535546
if int_index >= len(self._fields):
536547
raise IndexError("Argument out of range")
@@ -540,6 +551,11 @@ def get_string(self, str_index):
540551

541552

542553
class BaseResult(object):
554+
"""Provides base functionality for result objects.
555+
556+
Args:
557+
connection (mysqlx.connection.Connection): The Connection object.
558+
"""
543559
def __init__(self, connection):
544560
self._connection = connection
545561
self._protocol = self._connection.protocol
@@ -552,32 +568,63 @@ def __init__(self, connection):
552568
connection._active_result = None
553569

554570
def get_warnings(self):
571+
"""Returns the warnings.
572+
573+
Returns:
574+
list: The list of warnings.
575+
"""
555576
return self._warnings
556577

557578
def get_warnings_count(self):
579+
"""Returns the number of warnings.
580+
581+
Returns:
582+
int: The number of warnings.
583+
"""
558584
return len(self._warnings)
559585

560586

561587
class Result(BaseResult):
588+
"""Allows retrieving information about non query operations performed on
589+
the database.
590+
591+
Args:
592+
connection (mysqlx.connection.Connection): The Connection object.
593+
ids (list): A list of IDs.
594+
"""
562595
def __init__(self, connection, ids=None):
563596
super(Result, self).__init__(connection)
564597
self._ids = ids
565598
self._protocol.close_result(self)
566599

567600
def get_affected_items_count(self):
601+
"""Returns the number of affected items for the last operation.
602+
603+
Returns:
604+
int: The number of affected items.
605+
"""
568606
return self._rows_affected
569607

570608
def get_autoincrement_value(self):
609+
"""Returns the last insert id auto generated.
610+
611+
Returns:
612+
int: The last insert id.
613+
"""
571614
return self._generated_id
572615

573616
def get_document_id(self):
617+
"""Returns ID of the last document inserted into a collection.
618+
"""
574619
if self._ids is None:
575620
return None
576621
if len(self._ids) == 0:
577622
return None
578623
return self._ids[0]
579624

580625
def get_document_ids(self):
626+
"""Returns the list of generated documents IDs.
627+
"""
581628
return self._ids
582629

583630

@@ -596,12 +643,19 @@ def _init_result(self):
596643

597644
@property
598645
def count(self):
646+
"""int: The total of items.
647+
"""
599648
return len(self._items)
600649

601650
def __getitem__(self, index):
602651
return self._items[index]
603652

604653
def index_of(self, col_name):
654+
"""Returns the index of the column.
655+
656+
Returns:
657+
int: The index of the column.
658+
"""
605659
index = 0
606660
for col in self._columns:
607661
if col.get_column_name() == col_name:
@@ -634,27 +688,46 @@ def _page_in_items(self):
634688
return count
635689

636690
def fetch_all(self):
691+
"""Fetch all items.
692+
693+
Returns:
694+
list: The list of items.
695+
"""
637696
while True:
638697
if not self._page_in_items():
639698
break
640699
return self._items
641700

642701

643702
class RowResult(BufferingResult):
703+
"""Allows traversing the Row objects returned by a Table.select operation.
704+
705+
Args:
706+
connection (mysqlx.connection.Connection): The Connection object.
707+
"""
644708
def __init__(self, connection):
645709
super(RowResult, self).__init__(connection)
646710

647711
@property
648712
def columns(self):
713+
"""list: The list of columns.
714+
"""
649715
return self._columns
650716

651717

652718
class SqlResult(RowResult):
719+
"""Represents a result from a SQL statement.
720+
721+
Args:
722+
connection (mysqlx.connection.Connection): The Connection object.
723+
"""
653724
def __init__(self, connection):
654725
super(SqlResult, self).__init__(connection)
655726
self._has_more_results = False
656727

657728
def get_autoincrement_value(self):
729+
"""Returns the identifier for the last record inserted.
730+
"""
658731
return self._generated_id
659732

660733
def next_result(self):
@@ -666,6 +739,12 @@ def next_result(self):
666739

667740

668741
class DocResult(BufferingResult):
742+
"""Allows traversing the DbDoc objects returned by a Collection.find
743+
operation.
744+
745+
Args:
746+
connection (mysqlx.connection.Connection): The Connection object.
747+
"""
669748
def __init__(self, connection):
670749
super(DocResult, self).__init__(connection)
671750

lib/mysqlx/statement.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ def _having(self, condition):
146146
self._having = ExprParser(condition, not self._doc_based).expr()
147147

148148
def bind(self, *args):
149+
"""Binds a value to a specific placeholder.
150+
151+
Args:
152+
*args: The name of the placeholder and the value to bind.
153+
A :class:`mysqlx.DbDoc` object or a JSON string
154+
representation can be used.
155+
Raises:
156+
ProgrammingError: If the number of arguments is invalid.
157+
"""
149158
self._has_bindings = True
150159
count = len(args)
151160
if count == 1:

0 commit comments

Comments
 (0)