@@ -519,6 +519,12 @@ def Message(self):
519
519
520
520
521
521
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
+ """
522
528
def __init__ (self , rs , fields ):
523
529
self ._fields = fields
524
530
self ._resultset = rs
@@ -531,6 +537,11 @@ def __getitem__(self, index):
531
537
return self ._fields [index ]
532
538
533
539
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
+ """
534
545
int_index = self ._resultset .index_of (str_index )
535
546
if int_index >= len (self ._fields ):
536
547
raise IndexError ("Argument out of range" )
@@ -540,6 +551,11 @@ def get_string(self, str_index):
540
551
541
552
542
553
class BaseResult (object ):
554
+ """Provides base functionality for result objects.
555
+
556
+ Args:
557
+ connection (mysqlx.connection.Connection): The Connection object.
558
+ """
543
559
def __init__ (self , connection ):
544
560
self ._connection = connection
545
561
self ._protocol = self ._connection .protocol
@@ -552,32 +568,63 @@ def __init__(self, connection):
552
568
connection ._active_result = None
553
569
554
570
def get_warnings (self ):
571
+ """Returns the warnings.
572
+
573
+ Returns:
574
+ list: The list of warnings.
575
+ """
555
576
return self ._warnings
556
577
557
578
def get_warnings_count (self ):
579
+ """Returns the number of warnings.
580
+
581
+ Returns:
582
+ int: The number of warnings.
583
+ """
558
584
return len (self ._warnings )
559
585
560
586
561
587
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
+ """
562
595
def __init__ (self , connection , ids = None ):
563
596
super (Result , self ).__init__ (connection )
564
597
self ._ids = ids
565
598
self ._protocol .close_result (self )
566
599
567
600
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
+ """
568
606
return self ._rows_affected
569
607
570
608
def get_autoincrement_value (self ):
609
+ """Returns the last insert id auto generated.
610
+
611
+ Returns:
612
+ int: The last insert id.
613
+ """
571
614
return self ._generated_id
572
615
573
616
def get_document_id (self ):
617
+ """Returns ID of the last document inserted into a collection.
618
+ """
574
619
if self ._ids is None :
575
620
return None
576
621
if len (self ._ids ) == 0 :
577
622
return None
578
623
return self ._ids [0 ]
579
624
580
625
def get_document_ids (self ):
626
+ """Returns the list of generated documents IDs.
627
+ """
581
628
return self ._ids
582
629
583
630
@@ -596,12 +643,19 @@ def _init_result(self):
596
643
597
644
@property
598
645
def count (self ):
646
+ """int: The total of items.
647
+ """
599
648
return len (self ._items )
600
649
601
650
def __getitem__ (self , index ):
602
651
return self ._items [index ]
603
652
604
653
def index_of (self , col_name ):
654
+ """Returns the index of the column.
655
+
656
+ Returns:
657
+ int: The index of the column.
658
+ """
605
659
index = 0
606
660
for col in self ._columns :
607
661
if col .get_column_name () == col_name :
@@ -634,27 +688,46 @@ def _page_in_items(self):
634
688
return count
635
689
636
690
def fetch_all (self ):
691
+ """Fetch all items.
692
+
693
+ Returns:
694
+ list: The list of items.
695
+ """
637
696
while True :
638
697
if not self ._page_in_items ():
639
698
break
640
699
return self ._items
641
700
642
701
643
702
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
+ """
644
708
def __init__ (self , connection ):
645
709
super (RowResult , self ).__init__ (connection )
646
710
647
711
@property
648
712
def columns (self ):
713
+ """list: The list of columns.
714
+ """
649
715
return self ._columns
650
716
651
717
652
718
class SqlResult (RowResult ):
719
+ """Represents a result from a SQL statement.
720
+
721
+ Args:
722
+ connection (mysqlx.connection.Connection): The Connection object.
723
+ """
653
724
def __init__ (self , connection ):
654
725
super (SqlResult , self ).__init__ (connection )
655
726
self ._has_more_results = False
656
727
657
728
def get_autoincrement_value (self ):
729
+ """Returns the identifier for the last record inserted.
730
+ """
658
731
return self ._generated_id
659
732
660
733
def next_result (self ):
@@ -666,6 +739,12 @@ def next_result(self):
666
739
667
740
668
741
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
+ """
669
748
def __init__ (self , connection ):
670
749
super (DocResult , self ).__init__ (connection )
671
750
0 commit comments