PySecondo package¶
Subpackages¶
- PySecondo.config_pkg package
- PySecondo.libs_pkg package
- PySecondo.optimizer_pkg package
- PySecondo.secondo_datatypes_pkg package
- Submodules
- PySecondo.secondo_datatypes_pkg.Attribute module
- PySecondo.secondo_datatypes_pkg.Relation module
- PySecondo.secondo_datatypes_pkg.Tuple module
- PySecondo.secondo_datatypes_pkg.general_type module
- PySecondo.secondo_datatypes_pkg.secondo_bool module
- PySecondo.secondo_datatypes_pkg.secondo_int module
- PySecondo.secondo_datatypes_pkg.secondo_real module
- PySecondo.secondo_datatypes_pkg.secondo_string module
- PySecondo.secondo_datatypes_pkg.secondo_text module
- Module contents
Submodules¶
PySecondo.PySecondo module¶
Module contents¶
The module PySecondo implements an API for interaction between Python and Secondo. After stablishing connections to Secondo server and Optimizer server reading the cofiguration parameters from a file, the queries canbe executed.
-
class
PySecondo.Secondo¶ Bases:
objectThis class contains attributes and methods for connecting to a running Secondo server, executing commands and queries, returning the result sets and parsing the results to implemented data structurs in python.
-
__init__()¶ This constructor which reads from configuration file, connects to secondo server and initialises the object to connect to Optimizer server.
-
close()¶ This method closes the connections to Secondo server and consequently to Optimizer server.
-
async
command_exec(command, tupel_source=None)¶ This method executes the command/query in three categories (save, restore, general) by calling relevant functions, sets the attributes result_error_code, result_error_message and result of the Secondo object.
- Parameters
command – The command or query to be executed.
tupel_source – the source for producing a stream of tupels, needed by queries like pyreceive
which send a stream of tuples to Secondo server. :return: the result of command/ query as a python nested list.
-
async
connect()¶ This method connects to Secondo server using asyncio methods and sets the connection, stream- reader and writer attributes of the Secondo class.
-
fetch_relation_header()¶ This method returns the header of the relation in result set of secondo object. :return: The header of the relation in result set as a nested list.
-
fetch_result()¶ This method returns the result attribute of the Secondo object. :return: The result attribute of the Secondo object as list.
-
fetch_result_rows()¶ This method returns the result attribute of secondo object. :return: The result attribute of secondo represents the result as a list.
-
fetch_result_type()¶ This method returns the result_type attribute of secondo object. :return: The result_type attribute of secondo represents the datatype of result set e.g. int or nested list.
-
fetch_stream_result()¶ This method returns the attribute containing the stream of tupels received from Secondo server when the query contains the operator pysend. :return: The stream of tuples collected in a list of tuples after receiving.
-
get_bin_format()¶ This method returns the format of returned result of queries. :return: True if the result is a nested list in binary formet/ False if in plain text nested list.
-
get_opendb()¶ This method returns the open database attribute of secondo object. :return: The currently open database in Secondo server as string.
-
get_opt()¶ This method returns the opt attribute of secondo object. :return: The opt attribute of secondo represents an optimizer object.
-
get_password()¶ This method returns the password attributes of secondo object. :return: The password attributes of secondo object, which is given as plain text and needed for authentication in Secondo.
-
get_port()¶ This method returns the port attributes of Secondo object. :return: The port attributes of Secondo object, which consists of an integer number as port eg. 5678.
-
get_result_error_code()¶ This method returns the result_error_code attribute of the Secondo object. :return: An integer representing the error code after executing a command/ query.
-
get_result_error_message()¶ This method returns the result_error_message attribute of the Secondo object. :return: A string representing the error message after executing a command/ query.
-
get_sec_conn()¶ This method returns the connection attribute of Secondo object.
- Returns
The connection attribute of Secondo object.
-
get_sec_streams()¶ This method returns the stream reader/ writer attributes of Secondo object.
- Returns
The stream reader/ writer attributes of Secondo object.
-
get_server()¶ This method returns the server attributes of Secondo object.
- Returns
The server attributes of Secondo object, which consists of an IP-address eg. 127.0.0.0.
-
get_user()¶ This method returns the user attributes of secondo object. :return: The user attributes of secondo object needed for authentication in Secondo.
-
async
optimization_check(command)¶ This method checks if the query need to be optimized then returns the optimized command by calling the function opt_comm_exec() otherwise returns the unchanged query.
- Parameters
command – The command or query to be executed.
- Returns
The optimized query.
-
parse_result_to_relation()¶ This method parses the relation result of a query and converts it to a Relation type. :return: An object of type Relation.
-
parse_result_to_secondo_int()¶ This method parses the integer result of a query and converts it to a secondo_int type. :return: An object of type secondo_int.
-
parse_result_to_secondo_real()¶ This method parses the float result of a query and converts it to a secondo_real type. :return: An object of type secondo_real.
-
parse_stream_result_to_relation()¶ This method parses the stream of tuples received from Secondo server when the query contains the operator pysend and converts them to a relation. :return: A Relation containing the stream of tuples received from Secondo server.
-
async
reopen_db()¶ This method closes the currently open database and opens it again. It is needed after executing some query types like catalog updates.
- Returns
True/ False according to the success of operation.
-
set_bin_format(val)¶ This method returns the bin_format attribute of the Secondo object. :return: A Boolean representing the format of received result from Secondo, when True corresponds to Binary nested list, when False textual nested list.
-
set_opendb(db)¶ This method returns the opendb attribute of the Secondo object. :return: A string representing the currently open database.
-