# Working with Relational Tables from mysqlsh import mysqlx # Connect to server using a connection URL mySession = mysqlx.get_session( { 'host': 'localhost', 'port': 33060, 'user': '******', 'password': '******'} ) myDb = mySession.get_schema('test') # Accessing an existing table myTable = myDb.get_table('my_table') # Insert SQL Table data myTable.insert(['name','birthday','age']) \ .values('Sakila', mysqlx.date_value(2000, 5, 27), 16).execute() # Find a row in the SQL Table myResult = myTable.select(['_id', 'name', 'birthday']) \ .where('name like :name AND age < :age') \ .bind('name', 'S%') \ .bind('age', 20).execute() # Print result print myResult.fetch_all()
all_members = dir(mysqlx) # Remove the python built in members exports = [] for member in all_members: if not member.startswith('__'): exports.append(member) print('Exported Items:', len(exports)) print('get_session:', type(mysqlx.get_session), '\n') print('expr:', type(mysqlx.expr), '\n') print('dateValue:', type(mysqlx.date_value), '\n') print('help:', type(mysqlx.date_value), '\n') print('Type:', mysqlx.Type, '\n') print('LockContention:', mysqlx.LockContention, '\n') #@# mysqlx module: expression errors expr = mysqlx.expr() expr = mysqlx.expr(5) #@ mysqlx module: expression expr = mysqlx.expr('5+6') print(expr) #@ mysqlx module: date_value() diffrent parameters mysqlx.date_value(2025, 10, 15) mysqlx.date_value(2017, 12, 10, 10, 10, 10) mysqlx.date_value(2017, 12, 10, 10, 10, 10, 500000) mysqlx.date_value(2017, 12, 10, 10, 10, 10, 599999)
# Working with Relational Tables from mysqlsh import mysqlx # Connect to server using a connection URL mySession = mysqlx.get_session({ 'host': 'localhost', 'port': 33060, 'user': '******', 'password': '******' }) myDb = mySession.get_schema('test') # Accessing an existing table myTable = myDb.get_table('my_table') # Insert SQL Table data myTable.insert(['name','birthday','age']) \ .values('Sakila', mysqlx.date_value(2000, 5, 27), 16).execute() # Find a row in the SQL Table myResult = myTable.select(['_id', 'name', 'birthday']) \ .where('name like :name AND age < :age') \ .bind('name', 'S%') \ .bind('age', 20).execute() # Print result print myResult.fetch_all()
# Remove the python built in members exports = [] for member in all_members: if not member.startswith('__'): exports.append(member) print 'Exported Items:', len(exports) print 'get_session:', type(mysqlx.get_session), '\n' print 'expr:', type(mysqlx.expr), '\n' print 'dateValue:', type(mysqlx.date_value), '\n' print 'help:', type(mysqlx.date_value), '\n' print 'Type:', mysqlx.Type, '\n' print 'LockContention:', mysqlx.LockContention, '\n' #@# mysqlx module: expression errors expr = mysqlx.expr() expr = mysqlx.expr(5) #@ mysqlx module: expression expr = mysqlx.expr('5+6') print expr #@ mysqlx module: date_value() diffrent parameters mysqlx.date_value(2025, 10, 15); mysqlx.date_value(2017, 12, 10, 10, 10, 10); mysqlx.date_value(2017, 12, 10, 10, 10, 10, 500000); mysqlx.date_value(2017, 12, 10, 10, 10, 10, 599999);