SQL - SQLLine (SQL at the command line)

> (Data|State) Management and Processing > (Data Type|Data Structure) > (Relation|Table) - Tabular data > Structured Query Language (SQL)

1 - About

SQLLine is a java command line tool client

Advertising

3 - Example

3.1 - Execute a query and quit

  • Against a SQL Server database
 sqlline -u "jdbc:sqlserver://hostName.database.windows.net:1433;databaseName=dbName" -n login -p 'password' -e "select 1"

where:

  • -u <database url> the JDBC URL to connect to
  • -n <username> the username to connect as
  • -p <password> the password to connect as
  • -d <driver class> the driver class to use
  • -e <command>

3.2 - Testing connectivity with Ansible

playbook.yml
- name: Testing the JDBC connectivity
    command: "{{ sqlline_home }}/sqlline -u 'jdbc:sqlserver://{{ infa_db_endpoint }}:{{ infa_db_port }};databaseName={{ infa_domain_db_name }}' -n '{{ infa_db_user }}' -p '{{ infa_db_password }}' -e 'select 1'"
    register: jdbc_test_result
    changed_when: "jdbc_test_result.rc != 0"
    failed_when: "jdbc_test_result.rc != 0"

3.3 - Quit

  • !quit to quite

4 - Documentation / Reference

Advertising