Skip to content
5 changes: 5 additions & 0 deletions src/rdbms-connect/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.1.3
++++++
* Introduce query/sql file execution command as 'flexible server execute' command.
* [BREKAING CHANGE] Move query execution of the 'flexible server connect' command to 'flexible server execute' command.

0.1.2
++++++
* Improvements for the 'flexible server connect' command.
Expand Down
29 changes: 25 additions & 4 deletions src/rdbms-connect/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ To install the extension separately can run:
Then can run connect commands:

::
az postgres flexible-server connect -n testServer -u username -p password --postgres-query "select * from pg_user;" --output table
az postgres flexible-server connect -n testServer -u username -p password

::
az mysql flexible-server connect -n testServer -u username -p password --mysql-query "select host, user from mysql.user;" --output table
az mysql flexible-server connect -n testServer -u username -p password

::
az postgres flexible-server connect -n testServer -u username --interactive

::
az mysql flexible-server connect -n testServer -u username --interactive

::
az postgres flexible-server execute -n testServer -u username -p password --querytext "select * from pg_user;" --output table

::
az mysql flexible-server execute -n testServer -u username -p password --querytext "select host, user from mysql.user;" --output table

::
az postgres flexible-server execute -n testServer -u username -p password --file-path "./test.sql"

::
az mysql flexible-server execute -n testServer -u username -p password --file-path "./test.sql"

--------
Switches
Expand All @@ -38,5 +56,8 @@ The login password of the administrator.
**--database-name -d**
(Optional) The name of the database. Uses default database if no value provided.

**--postgres-query / --mysql-query -c**
(Optional) A query to run against the flexible server.
**--querytext -q**
A query to run against the flexible server.

**--file-path -f**
A sql file to run against the flexible server.
24 changes: 20 additions & 4 deletions src/rdbms-connect/azext_rdbms_connect/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
example:
- name: Connect to a flexible server using administrator username and password. Default database is used if not specified.
text: az mysql flexible-server connect -n testServer -u username -p password -d flexibleserverdb
- name: Connect to a flexible server and execute a query with results outputted in a table.
Comment thread
DaeunYim marked this conversation as resolved.
text: az mysql flexible-server connect -n testServer -u username -p password --querytext "select host, user from mysql.user;" --output table
- name: Connect to a flexible server and run queries interactively.
text: az mysql flexible-server connect -n testServer -u username --interactive
"""
Expand All @@ -24,8 +22,26 @@
example:
- name: Connect to a flexible server using administrator username and password. Default database is used if not specified.
text: az postgres flexible-server connect -n testServer -u username -p password -d postgres
- name: Connect to a flexible server and execute a query with results outputted in a table.
text: az postgres flexible-server connect -n testServer -u username -p password --querytext "select * from pg_user;" --output table
- name: Connect to a flexible server and run queries interactively.
text: az postgres flexible-server connect -n testServer -u username --interactive
"""

helps['mysql flexible-server execute'] = """
type: command
short-summary: Connect to a flexible server.
example:
- name: Connect to a flexible server and execute a query with results outputted in a table.
text: az mysql flexible-server execute -n testServer -u username -p password --querytext "select host, user from mysql.user;" --output table
- name: Connect to a flexible server and execute a sql file.
text: az mysql flexible-server execute -n testServer -u username -p password --file-path path_to_sql_file
"""

helps['postgres flexible-server execute'] = """
type: command
short-summary: Connect to a flexible server.
example:
- name: Connect to a flexible server and execute a query with results outputted in a table.
text: az postgres flexible-server execute -n testServer -u username -p password --querytext "select * from pg_user;" --output table
- name: Connect to a flexible server and execute a sql file.
text: az mysql flexible-server execute -n testServer -u username -p password --file-path path_to_sql_file
"""
10 changes: 10 additions & 0 deletions src/rdbms-connect/azext_rdbms_connect/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ def load_arguments(self, _):
help='The login password of the administrator.')
c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('interactive_mode', options_list=['--interactive'], action='store_true', help='Pass this parameter to connect to database in interactive mode.')
c.argument('querytext', options_list=['--querytext', '-q'], deprecate_info=c.deprecate(redirect='execute'), help='A query to run against the flexible server.')

with self.argument_context('{} flexible-server execute'.format(command_group)) as c:
c.argument('server_name', id_part=None, options_list=['--name', '-n'], arg_type=server_name_arg_type)
c.argument('administrator_login', arg_group='Authentication', arg_type=administrator_login_arg_type, options_list=['--admin-user', '-u'],
help='The login username of the administrator.')
c.argument('administrator_login_password', arg_group='Authentication', options_list=['--admin-password', '-p'],
help='The login password of the administrator.')
c.argument('database_name', arg_type=database_name_arg_type, options_list=['--database-name', '-d'], help='The name of a database.')
c.argument('querytext', options_list=['--querytext', '-q'], help='A query to run against the flexible server.')
c.argument('file_path', options_list=['--file-path', '-f'], help='The path of the sql file to execute.')
2 changes: 2 additions & 0 deletions src/rdbms-connect/azext_rdbms_connect/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ def load_command_table(self, _):
client_factory=cf_mysql_flexible_location_capabilities,
is_preview=True) as g:
g.custom_command('connect', 'connect_to_flexible_server_mysql')
g.custom_command('execute', 'execute_flexible_server_mysql')

with self.command_group('postgres flexible-server', postgres_flexible_location_capabilities_sdk,
client_factory=cf_postgres_flexible_location_capabilities,
is_preview=True) as g:
g.custom_command('connect', 'connect_to_flexible_server_postgres')
g.custom_command('execute', 'execute_flexible_server_postgres')
Loading