00017 :
00018 print """Database Updater Utility
00019
00020 Note: Before invoking this utility the following database environmental variables must be set:-
00021
00022 SK_TSQL_URL This is a semi-colon separated list of URLs. Each URL takes the form:-
00023 protocol://host[:port]/[database]
00024 where:
00025 protocol - mysql
00026 host - host name or IP address of database server
00027 port - port number
00028 database - name of database
00029 Example: mysql://myhost:3306/test
00030
00031 SK_TSQL_USER The account user name. If different names for different databases in the cascade
00032 then this can be a semi-colon separated list in the same order as SK_TSQL_URL.
00033 If the list is shorter than that list, then the first entry is used for the missing entries.
00034
00035 SK_TSQL_PSWD The account password here. As with SK_TSQL_USER it can be a semi-colon separated list
00036 with the first entry providing the default if the list is shorter than SK_TSQL_URL.
00037
00038 Although the oaOfflineDatabase supports multi-database environmental variables this utility ALWAYS
00039 uses the first entry.
00040
00041 Invocation: database_updater.py [<options>] <command> [<arg>]
00042
00043 <options> are:-
00044
00045 --convert_unsigned
00046 Convert ANY integer data > 2147483647 to signed before
00047 storing by subtracting 4294967296. Useful for unsigned channel IDs.
00048 CAUTION: Don't use if table contains BIGINTs.
00049 --debug Print out all MySQL commands
00050 --help Prints this help.
00051
00052 <command> [<arg>] is one of:-
00053
00054 apply_global_update <update-file>
00055 Applies update using global sequence numbers (SEQNOs)
00056 - fails if not authorising DB i.e. does not have a GLOBALSEQNO table
00057
00058 apply_local_update <update-file>
00059 Applies update using local sequence numbers (SEQNOs)
00060
00061 drop_table <table-name>
00062 Removes table (main and VLD) and any entry in GLOBALSEQNO and LOCALSEQNO tables
00063 - asks confirmation if DB is authorising i.e. has a GLOBALSEQNO table
00064
00065 <update-file> can contain any number of the following:-
00066
00067 o Blank lines and comments (# in column 1)
00068
00069 o SQL <sql-command>;
00070 Any arbitrary SQL command that ends with a ';'. Can span several lines.
00071 e.g. SQL drop table
00072 if exists DEMO_DB_TABLE;
00073
00074 o BEGIN_TABLE <table-name> <start-date> <end-date> <aggregate-number> <creation-date> {<task>} {<key>=<value> ...}
00075 If not supplied a value of 0 is assumed for <task>.
00076 Valid <key>=<value> sets are:-
00077 SIMMASK=<value> where <value> is one of: 'Data', 'MC' or 'all'
00078 EPOCH=<value> where <value> is a small integer in range 0..100
00079 Note: If creating the VLD table, this forces it to have EPOCH and REALITY columns
00080 Although it is not required, this should be used for all new entries.
00081 If using a <key>=<value> set the task value must also be supplied.
00082 Followed by one or more rows of data, one per line in the form <value>,<value>, ... <value>
00083 This utility supplies both SEQNO and ROW_COUNTER to the start of each row
00084 e.g. BEGIN_TABLE DEMO_DB_TABLE '2009-01-01 00:00:00' '2009-02-00 00:00:00' 0 '2009-04-07 18:00:00' 0 EPOCH=0
00085 -2006450160, 101, 201, 301, 1.01, 2.01, 3.01
00086 -2006450170, 102, 202, 302, 1.02, 2.02, 3.02
00087
00088 """
00089
00090
00091
00092
class DatabaseInterface: