PDF (US Ltr)
- 1.2Mb
PDF (A4)
- 1.2Mb
In this example a connection to a local MySQL Server instance
running X Plugin on the default TCP/IP port 33060 is
established using the MySQL user account
user
with its password. As no other
parameters are set, default values are used.
Press CTRL+C to copy# Passing the parameters in the { param: value } format dictSession = mysqlx.get_session( { 'host': 'localhost', 'port': 33060, 'user': 'user', 'password': 'password' } ) db1 = dictSession.get_schema('test') # Passing the parameters in the URI format uriSession = mysqlx.get_session('user:password@localhost:33060') db2 = uriSession.get_schema('test')
The following example shows how to connect to a single MySQL Server instance by providing a TCP/IP address “localhost” and the same user account as before. You are prompted to enter the user name and password in this case.
Press CTRL+C to copy# Passing the parameters in the { param: value } format # Query the user for the account information print("Please enter the database user information.") usr = shell.prompt("Username: ", {'defaultValue': "user"}) pwd = shell.prompt("Password: ", {'type': "password"}) # Connect to MySQL Server on a network machine mySession = mysqlx.get_session( { 'host': 'localhost', 'port': 33060, 'user': usr, 'password': pwd} ) myDb = mySession.get_schema('test')