# Assumptions: ensure_schema_does_not_exist is available # Assumes __uripwd is defined as <user>:<pwd>@<host>:<mysql_port> from mysqlsh import mysql mySession = mysql.get_classic_session(__uripwd) ensure_schema_does_not_exist(mySession, 'js_shell_test') schema = mySession.create_schema('js_shell_test') mySession.set_current_schema('js_shell_test') result = mySession.run_sql('create table table1 (name varchar(50))') result = mySession.run_sql('create view view1 (my_name) as select name from table1') view = mySession.get_schema('js_shell_test').get_table('view1') #@ Testing view name retrieving print 'get_name(): ' + view.get_name() print 'name: ' + view.name #@ Testing session retrieving print 'get_session():', view.get_session() print 'session:', view.session #@ Testing view schema retrieving print 'get_schema():', view.get_schema() print 'schema:', view.schema #@ Testing existence print 'Valid:', view.exists_in_database()
# __user: <user> # __uripwd: <uri>:<pwd>@<host> # __pwd: <pwd> #@ mysql module: exports all_exports = dir(mysql) # Remove the python built in members exports = [] for member in all_exports: if not member.startswith('__'): exports.append(member) # The dir function appends 3 built in members print 'Exported Items:', len(exports) validateMember(exports, 'get_classic_session') validateMember(exports, 'get_session') validateMember(exports, 'help') #@# get_classic_session errors mysql.get_classic_session() mysql.get_classic_session(1, 2, 3) mysql.get_classic_session(["bla"]) mysql.get_classic_session("some@uri", 25) #@# get_session errors mysql.get_session() mysql.get_session(1, 2, 3) mysql.get_session(["bla"]) mysql.get_session("some@uri", 25)
def check_super_read_only_done(connection): global ro_session ro_session = ro_module.get_classic_session(connection) wait(60, 1, wait_super_read_only_done) ro_session.close()
cluster.describe() #@<OUT> Cluster: status after adding read only instance back cluster.status() # Make sure uri2 is selected as the new master cluster.remove_instance(uri3) #@ Cluster: remove_instance master cluster.remove_instance(uri1) #@ Connecting to new master from mysqlsh import mysql customSession = mysql.get_classic_session({ "host": localhost, "port": __mysql_sandbox_port2, "user": '******', "password": '******' }) dba.reset_session(customSession) cluster = dba.get_cluster() # Add back uri3 add_instance_to_cluster(cluster, __mysql_sandbox_port3, 'third_sandbox') wait_slave_state(cluster, 'third_sandbox', "ONLINE") #@<OUT> Cluster: describe on new master cluster.describe() #@<OUT> Cluster: status on new master cluster.status()
# Assumptions: ensure_schema_does_not_exist is available # Assumes __uripwd is defined as <user>:<pwd>@<host>:<mysql_port> # validateMemer and validateNotMember are defined on the setup script from mysqlsh import mysql #@ Session: validating members classicSession = mysql.get_classic_session(__uripwd) all_members = dir(classicSession) # Remove the python built in members sessionMembers = [] for member in all_members: if not member.startswith('__'): sessionMembers.append(member) validateMember(sessionMembers, 'close') validateMember(sessionMembers, 'create_schema') validateMember(sessionMembers, 'get_current_schema') validateMember(sessionMembers, 'get_default_schema') validateMember(sessionMembers, 'get_schema') validateMember(sessionMembers, 'get_schemas') validateMember(sessionMembers, 'get_uri') validateMember(sessionMembers, 'set_current_schema') validateMember(sessionMembers, 'query') validateMember(sessionMembers, 'run_sql') validateMember(sessionMembers, 'default_schema') validateMember(sessionMembers, 'uri') validateMember(sessionMembers, 'current_schema') #@ ClassicSession: accessing Schemas
# Assumptions: ensure_schema_does_not_exist is available # Assumes __uripwd is defined as <user>:<pwd>@<host>:<mysql_port> # validateMemer and validateNotMember are defined on the setup script from mysqlsh import mysql #@ Session: validating members classicSession = mysql.get_classic_session(__uripwd) all_members = dir(classicSession) # Remove the python built in members sessionMembers = [] for member in all_members: if not member.startswith('__'): sessionMembers.append(member) validateMember(sessionMembers, 'close') validateMember(sessionMembers, 'create_schema') validateMember(sessionMembers, 'get_current_schema') validateMember(sessionMembers, 'get_default_schema') validateMember(sessionMembers, 'get_schema') validateMember(sessionMembers, 'get_schemas') validateMember(sessionMembers, 'get_uri') validateMember(sessionMembers, 'set_current_schema') validateMember(sessionMembers, 'run_sql') validateMember(sessionMembers, 'default_schema') validateMember(sessionMembers, 'uri') validateMember(sessionMembers, 'current_schema') #@ ClassicSession: validate dynamic members for system schemas sessionMembers = dir(classicSession) validateNotMember(sessionMembers, 'mysql')
all_exports = dir(mysql) # Remove the python built in members exports = [] for member in all_exports: if not member.startswith('__'): exports.append(member) # The dir function appends 3 built in members print 'Exported Items:', len(exports) print 'get_classic_session:', type(mysql.get_classic_session) print 'help:', type(mysql.get_classic_session) #@ mysql module: get_classic_session through URI mySession = mysql.get_classic_session(__uripwd) print mySession, '\n' if mySession.uri == __displayuri: print 'Session using right URI\n' else: print 'Session using wrong URI\n' mySession.close() #@ mysql module: get_classic_session through URI and password mySession = mysql.get_classic_session(__uri, __pwd) print mySession, '\n'
# __uripwd: <uri>:<pwd>@<host> # __pwd: <pwd> #@ mysql module: exports all_exports = dir(mysql) # Remove the python built in members exports = [] for member in all_exports: if not member.startswith('__'): exports.append(member) # The dir function appends 3 built in members print 'Exported Items:', len(exports) validateMember(exports, 'get_classic_session'); validateMember(exports, 'get_session'); validateMember(exports, 'help'); #@# get_classic_session errors mysql.get_classic_session() mysql.get_classic_session(1, 2, 3) mysql.get_classic_session(["bla"]) mysql.get_classic_session("some@uri", 25) #@# get_session errors mysql.get_session() mysql.get_session(1, 2, 3) mysql.get_session(["bla"]) mysql.get_session("some@uri", 25)