Business Shell (BUSH) Guide
Author: Ken Burtch

Home Page | Introduction | Tutorials | Reference | Packages | Hacking

Packages
4.1 Using Packages
4.2 text_io (Console I/O)
4.3 text_io (File I/O)
4.4 sound
4.5 source_info
4.6 System
4.7 numerics
4.8 strings
4.9 command_line
4.10 lock_files
4.11 cgi
4.12 calendar
4.13 units
4.14 arrays
4.15 files
4.16 db (Database)
4.17 stats
4.18 pen
4.19 mysql
4.20 os
4.21 directory_operations
| This part of the guide contains detailed descriptions of the BUSH built-in packages. ### 4.19 MySQL Database Package The database package is based on Warren Gay's APQ MySQL binding. For full details on these routines, consult the APQ documentation. There is an enumerated type in the db package that controls the verbosity of tracing: `type db.trace_mode_type is ( db.trace_none, db.trace_db, db.trace_apq, db.trace_full );` There is an enumerated type that controls file access: `type mysql.mode_type is ( mysql.read, mysql.write, mysql.read_write );` There is an enumerated type in the db package that controls fetch order: `type db.fetch_mode_type is ( db.sequential_fetch, db.random_fetch );` There is an enumerated type in the db package that identifies the database engine: `type db.database_type is ( db.engine_postgresql, db.engine_mysql, db.engine_oracle, db.engine_sybase, db.engine_db2 );` mysql.append( s [, a] )
Append text to an SQL query s after a (?) Example: mysql.append( " where customer_no > 5" ); Ada Equivalent: APQ.Append Parameters:
s | in | string | required | SQL query
a | in | string | empty string | after (not quite sure)
mysql.append_line( s )
Start a new line and append line to SQL query s Example: mysql.append_line( "where customer_no > 5" ); Ada Equivalent: APQ.Append_Line Parameters:
s | in | string | required | SQL query text
mysql.append_quoted( s )
Append text to SQL query s and surrounded text with single quotes. Example: mysql.append_quoted( "customer_name" ); Ada Equivalent: APQ.Append_Quoted Parameters:
s | in | string | required | SQL query text
a | in | string | "" | after what query text
mysql.begin_work
Start a database transaction, marking the position of a possible rollback. Example: mysql.begin_work; Ada Equivalent: APQ.Begin_Work Parameters:
none
in_abort_state exception may be raised mysql.clear
Erase the current query. Example: mysql.clear; Ada Equivalent: APQ.Clear Parameters:
none
If a connection doesn't exist, an error will occur. mysql.close_db_trace
Stop tracing the database activity and close the trace file. Example: mysql.close_db_trace; Ada Equivalent: APQ.Close_DB_Trace Parameters:
none
If a connection doesn't exist, an error will occur. i := mysql.column_index( s )
Return the position of a query result column. This is the position in the query, not the database table. Example: third_column_position := mysql.column_index( "first name" ); Ada Equivalent: APQ.Column_Name Parameters:
c | in | string | the column heading
i | return value | column_index_type | the column position in the query
no_column exception may be raised s := mysql.column_name( c )
Return the name of a query result column. The number is the position in the query, not the database table. Example: third_column_heading := mysql.column_name( 3 ); Ada Equivalent: APQ.Column_Name Parameters:
c | in | column_index_type | the column position in the query results
s | return value | string | the column heading
no_column exception may be raised n := mysql.columns
Return the number of columns (fields) from the last query. Example: number_of_columns := mysql.columns; Ada Equivalent: APQ.Columns Parameters:
n | return value | natural | the number of columns
no_result exception may be raised mysql.commit_work
Complete a database transaction. Example: mysql.commit_work; Ada Equivalent: APQ.Commit_Work Parameters:
none
in_abort_state exception may be raised mysql.connect( d [, u, p ][, h][, p] )
Connect to database d using username u, path p, hostname h and port p. If no hostname or port are specified, connection is made by a UNIX socket instead of a network socket. Example: mysql.connect( "db", "user", "password" ); Ada Equivalent: combines several APQ functions Parameters:
d | in | string | required | the database name
u | in | string | your username | the username to connect with
p | in | string | default password | username's password
h | in | string | UNIX Socket | hostname for network socket
p | in | string | default port | network socket port
If a connection cannot be made, an error will occur. mysql.databases
Show a list of the databases available with the current connection. This is the equivalent of MySQL "show databases". Example: mysql.databases; Ada Equivalent: none (AdaScript extension) Parameters:
none
If a connection doesn't exist, an error will occur. mysql.disconnect
Close a connection created by connect. Example: mysql.disconnect; Ada Equivalent: APQ.Disconnect; Parameters:
none
If a connection doesn't exist, an error will occur. b := mysql.end_of_query
True if there are no more result (tuple) rows. Example: b := mysql.end_of_query; Ada Equivalent: APQ.End_Of_Query Parameters:
b | return value | boolean | true if no more rows
b := mysql.engine_of
Return the identity of the database engine Example: b := mysql.engine_of; Ada Equivalent: APQ.Engine_Of Parameters:
b | return value | db.database_type | db.engine_mysql, etc.
s := mysql.error_message
Last error message returned by database server. Example: err := mysql.error_message; Ada Equivalent: APQ.Error_Message; Parameters:
b | return value | string | last server message
mysql.execute
Run a prepared database query. Example: mysql.execute; Ada Equivalent: APQ.Execute Parameters:
none
If a connection doesn't exist, an error will occur. mysql.execute_checked( [ s ] )
not sure the difference with execute. Example: mysql.execute_checked( "message" ); Ada Equivalent: APQ.Execute_Checked Parameters:
s | in | string | empty string | a message
mysql.fetch [ (i) ]
Fetch the next query result tuple row, or a specific result row. Example: mysql.fetch; Ada Equivalent: APQ.Fetch Parameters:
i | in | tuple_index_type | optional | a specific result row
no_result or no_tuple exceptions may be raised. s := mysql.in_abort_state
True if in abort state. Example: b := mysql.in_abort_state; Ada Equivalent: APQ.In_Abort_State; Parameters:
b | return value | boolean | true if in abort state
If a connection doesn't exist, a not connected exception will occur. b := mysql.is_connected
True if Bush is connected to a database. Example: b := mysql.is_connected; Ada Equivalent: APQ.Is_Connected; Parameters:
b | return value | boolean | true if connected
If a connection doesn't exist, an error will occur. b := mysql.is_null( c )
True if column in the fetch result is undefined. Example: b := mysql.is_null; Ada Equivalent: APQ.Is_Null Parameters:
c | in | mysql.column_index_type | the field to check
b | return value | boolean | true if null
no_column and no_result exceptions may be raised b := mysql.is_trace
True if set_trace was true (that is, if debug tracing is enabled). Example: b := mysql.is_trace; Ada Equivalent: APQ.Is_Trace Parameters:
b | return value | boolean | tracing is enabled
mysql.list
Show a list of the tables available in the current database. This is the equivalent of MySQL's "show tables". Example: mysql.list; Ada Equivalent: none (AdaScript extension) Parameters:
none
If a connection doesn't exist, an error will occur. mysql.open_db_trace( f )
Begin tracing the database activity, storing the results at pathname f. Example: mysql.open_db_trace( "./trace.out" ); Ada Equivalent: APQ.Open_DB_Trace Parameters:
f | in | string | required | trace file pathname
If a connection doesn't exist, an error will occur. not_connected, file already open, file not found exceptions may be raised s := mysql.options
Return database options. Example: b := mysql.options; Ada Equivalent: APQ.Options Parameters:
b | return value | string | database options
mysql.prepare( s [, a] )
Prepare a SQL statement to execute. If a is included, insert the next statement after the statement named a. Example: mysql.prepare( "select * from customers" ); Ada Equivalent: APQ.Prepare Parameters:
s | in | string | required | SQL statement
a | in | string | after all others | insert SQL statement after statement a
If a connection cannot be made, an error will occur. mysql.raise_exceptions( [ b ] )
True to raise exceptions on query. Example: mysql.raise_exceptions( false ); Ada Equivalent: APQ.Raise_Exceptions Parameters:
b | in | boolean | true | whether or not exceptions will occur
mysql.report_errors( b )
True to report errors on query. Example: mysql.report_errors( false ); Ada Equivalent: APQ.Report_Errors Parameters:
b | in | boolean | true | whether or not errors will be reported
mysql.reset
APQ reset command (not quite sure...). Reset the database connection. Example: mysql.reset; Ada Equivalent: APQ.Reset; Parameters:
none
If a connection doesn't exist, an error will occur. mysql.rewind
Return to the start of a query's results. Example: mysql.rewind; Ada Equivalent: APQ.Rewind Parameters:
none
mysql.rollback_work
Rollback a database transaction, undoing all work since begin_work. Example: mysql.rollback_work; Ada Equivalent: APQ.Rollback_Work Parameters:
none
in_abort_state exception may be raised mysql.schema( t )
Show information about the columns in a table. This is the equivalent of MySQL's "show columns". Example: mysql.schema( "table" ); Ada Equivalent: none (AdaScript extension) Parameters:
t | in | string | required | name of the table
mysql.set_rollback_on_finalize( b )
Determine if a rollback will be issued when the script ends and the database connection is still open (true) or no rollback (false). Default is true. Example: mysql.set_rollback_on_finalize( false ); Ada Equivalent: APQ.Set_Rollback_On_Finalize Parameters:
b | in | boolean | true | whether or not rollback will occur
mysql.set_trace( b )
Determine if debug tracing is enabled. Example: mysql.set_trace( false ); Ada Equivalent: APQ.Set_Trace Parameters:
b | in | boolean | true | whether or not tracing will occur
mysql.show
Run the prepared query and show the results in a table on standard output. This is often used to show the results of a SQL SELECT statement. Example: mysql.show; Ada Equivalent: none (AdaScript extension) Parameters:
none
If a connection doesn't exist, an error will occur. t := mysql.tuple
Return the result row (tuple) number from the last fetch. Example: row_number := mysql.tuple; Ada Equivalent: APQ.Tuple Parameters:
t | return value | mysql.tuple_index_type | the current row number
no_tuple exception may be raised n := mysql.tuples
Return the number of rows (tuples) from the last query. Example: row_number := mysql.tuples; Ada Equivalent: APQ.Tuples Parameters:
t | return value | mysql.tuple_count_type | the number of rows
no_result exception may be raised mysql.users
Show a list of database users. This is similar to MySQL's "show grants". The columns in the list depend on the database engine. Example: mysql.users; Ada Equivalent: none (AdaScript extension) Parameters:
none
If a connection doesn't exist, an error will occur. s := mysql.value( c )
Return the column value as a string. Example: first_name := mysql.value( 3 ); Ada Equivalent: APQ.Value Parameters:
c | in | mysql.column_index_type | the field to return
s | return value | universal_typeless | the value of the field
no_column, no_result, null_value and no_tuple exceptions may be raised b := mysql.will_rollback_on_finalize
True if set_rollback_on_finalize was true (that is, that when the script finishes, a rollback will be issued if the connection is still open). Example: b := mysql.will_rollback_on_finalize; Ada Equivalent: APQ.Will_Rollback_On_Finalize Parameters:
b | return value | boolean | rollback will be issued on finalize
Back to Top