Brian Daniels / mbed-tools

Fork of mbed-tools by Morpheus

Embed: (wiki syntax)

« Back to documentation index

MySQLDBAccess Class Reference

MySQLDBAccess Class Reference

Inherits tools::test_db::BaseDBAccess.

Public Member Functions

def detect_database
def parse_db_connection_string
def is_connected
def connect
def connect_url
def reconnect
def disconnect
def escape_string
def select_all
def insert
def get_next_build_id
def get_table_entry_pk
def update_table_entry
def update_build_id_info
def insert_test_entry

Detailed Description

Wrapper for MySQL DB access for common test suite interface

Definition at line 27 of file test_mysql.py.


Member Function Documentation

def connect (   self,
  host,
  user,
  passwd,
  db 
)
Connects to DB and returns DB object

Definition at line 66 of file test_mysql.py.

def connect_url (   self,
  db_url 
)
Connects to database using db_url (database url parsing),
    store host, username, password, db_name

Definition at line 86 of file test_mysql.py.

def detect_database (   self,
  verbose = False 
)
detect database and return VERION data structure or string (verbose=True)

Definition at line 34 of file test_mysql.py.

def disconnect (   self )
Close DB connection

Definition at line 102 of file test_mysql.py.

def escape_string (   self,
  str 
)
Escapes string so it can be put in SQL query between quotes

Definition at line 110 of file test_mysql.py.

def get_next_build_id (   self,
  name,
  desc = '',
  location = '',
  type = None,
  status = None 
)
Insert new build_id (DB unique build like ID number to send all test results)

Definition at line 136 of file test_mysql.py.

def get_table_entry_pk (   self,
  table,
  column,
  value,
  update_db = True 
)
Checks for entries in tables with two columns (<TABLE_NAME>_pk, <column>)
    If update_db is True updates table entry if value in specified column doesn't exist

Definition at line 160 of file test_mysql.py.

def insert (   self,
  query,
  commit = True 
)
Execute INSERT query, define if you want to commit

Definition at line 126 of file test_mysql.py.

def insert_test_entry (   self,
  build_id,
  target,
  toolchain,
  test_type,
  test_id,
  test_result,
  test_output,
  test_time,
  test_timeout,
  test_loop,
  test_extra = '' 
)
Inserts test result entry to database. All checks regarding existing
    toolchain names in DB are performed.
    If some data is missing DB will be updated

Definition at line 232 of file test_mysql.py.

def is_connected (   self )
Returns True if we are connected to database

Definition at line 61 of file test_mysql.py.

def parse_db_connection_string (   self,
  str 
)
Parsing SQL DB connection string. String should contain:
    - DB Name, user name, password, URL (DB host), name
    Function should return tuple with parsed (host, user, passwd, db) or None if error
    E.g. connection string: 'mysql://username:password@127.0.0.1/db_name'

Definition at line 48 of file test_mysql.py.

def reconnect (   self )
Reconnects to DB and returns DB object using stored host name,
    database name and credentials (user name and password)

Definition at line 96 of file test_mysql.py.

def select_all (   self,
  query 
)
Execute SELECT query and get all results

Definition at line 117 of file test_mysql.py.

def update_build_id_info (   self,
  build_id,
  kw 
)
Update additional data inside build_id table
    Examples:
    db.update_build_id_info(build_id, _status_fk=self.BUILD_ID_STATUS_COMPLETED, _shuffle_seed=0.0123456789):

Definition at line 209 of file test_mysql.py.

def update_table_entry (   self,
  table,
  column,
  value 
)
Updates table entry if value in specified column doesn't exist
    Locks table to perform atomic read + update

Definition at line 181 of file test_mysql.py.