Q26 ALPHA-TRADING SYSTEM
Public Member Functions | Public Attributes | List of all members
SQL Class Reference

Public Member Functions

def __init__ (self)
 
def to_SQL_type (self, type_, mode="format")
 
def create_database (self, path)
 
def connect_database (self, path)
 
def execute (self, action=None, object=None, argument=None)
 
def get_table_list (self)
 
def get_id_list (self, table)
 
def create_table (self, name, structure)
 
def insert (self, table, value)
 
def delete (self, table, where_=None)
 
def drop_table (self, table)
 
def select (self, distinct=False, columns=["*"], table=None, where_=None, orderby_=None, ordering="ASC" # "DESC")
 

Public Attributes

 path
 
 connexion
 
 cursor
 
 verbose
 

Member Function Documentation

◆ connect_database()

def connect_database (   self,
  path 
)
Function allowing to connect to an existing database

Parameter: 
    - path [str]: Path and name of the database. Note: The folder should exist.

Returns: 
    None 

◆ create_database()

def create_database (   self,
  path 
)
Function allowing to create a database. 

Parameter: 
    - path [str]: Path and name of the database. Note: The folder should exist. 

Returns: 
    None 

◆ create_table()

def create_table (   self,
  name,
  structure 
)
Function allowing to create a table in the already existing database 

Parameters: 
    - name [str]: Name of the table 
    - structure [dict]: Structure of the table. Keys corresponds to the name of the columns while 
                        associated values corresponds to the anounced type of the data.

Returns: 
    None 

◆ delete()

def delete (   self,
  table,
  where_ = None 
)
Function allowing to delete an element from a table in the database. 

Parameters: 
    - table              [str]: Name of the table 
    - where_ [list(dict, str, list)]: List of conditions defining elements to be deleted. The structure of this
                                variable follows the scheme below: 
                                [{
                                    "object"  : #Define the attribute name of an element, 
                                    "operator": #Define an operator defined in python syntax but provided inside a string 
                                    "value"   : #A value which close the conditional statement 
                                }, 
                                logic_operator [str] (it may be : "and", "or", "not"...)
                                ...
                                The sequence of conditions has to follow logical rules otherwise it will probably raise an error.  
                                ]

◆ drop_table()

def drop_table (   self,
  table 
)
Function allowing to drop a table from the database 

Parameters: 
    - table [str]: Table name 

Returns: 
    None 

◆ execute()

def execute (   self,
  action = None,
  object = None,
  argument = None 
)
Function that execute every command following the SQL query 
structure. 

◆ get_id_list()

def get_id_list (   self,
  table 
)
Function that retrieves the list of ids of the elements within 
a table. If the tabe doesn't contain any elements, it return 
the following list: [0]

Parameters: 
    - table [str]: Table name 

Returns: 
    - [int]: List of ids of the elements in the table 
             in the order they have been added 

◆ get_table_list()

def get_table_list (   self)
Function returning the list of tables in the database 

Parameters: 
    None 

Returns: 
    - [list(str)]: ["table_name1", "table_name2", ...]

◆ insert()

def insert (   self,
  table,
  value 
)
Function allowing to insert an element in an existing table 
of the connected database 

Parameters: 
    - tableĀ [str]  : Name of the table 
    - value [list] : List of the attributes of the element to be 
                     inserted 

Returns: 
    None  

◆ to_SQL_type()

def to_SQL_type (   self,
  type_,
  mode = "format" 
)
Function allowing to convert element type expressed in Python syntax into type 
expressed into SQL syntax. 

Parameter: 
    - type_ [str]: Types have to be committed as a string format 

Returns: 
    - [str]: The parameter type converted in the SQL format if the type is considered in the method. 
             The input variable otherwise. 

The documentation for this class was generated from the following file: