http://software.clapper.org/sqlshell/users-guide.html
Note: Assuming SQLShell is already installed and instructions below are for Mac OSX
1. Create a file in $HOME/.sqlshell/config as shown below, I just took the sample it ships with. Notice how I have added an alias for "gemfirexd", highlighted below.
# ---------------------------------------------------------------------------
# initialization file for SQLShell
[settings]
#colspacing: 2
[drivers]
# Driver aliases.
postgresql = org.postgresql.Driver
postgres = org.postgresql.Driver
mysql = com.mysql.jdbc.Driver
sqlite = org.sqlite.JDBC
sqlite3 = org.sqlite.JDBC
oracle = oracle.jdbc.driver.OracleDriver
access = sun.jdbc.odbc.JdbcOdbcDriver
gemfirexd = com.pivotal.gemfirexd.jdbc.ClientDriver
[vars]
historyDir: ${env.HOME}/.sqlshell
[db_postgres]
aliases: post
url: jdbc:postgresql://localhost:5432/sampledb
driver: postgres
user: ${system.user.name}
password:
history: $vars.historyDir/postgres.hist
[db_mysql]
#aliases:
driver: mysql
url: jdbc:mysql://localhost:3306/sampledb
user: ${system.user.name}
password:
history: $vars.historyDir/mysql.hist
[db_sqlite3]
aliases: sqlite3
url: jdbc:sqlite:/tmp/sample.db
driver: sqlite
history: $vars.historyDir/sqlite3.hist
[db_oracle]
aliases: ora
schema: example
url: jdbc:oracle:thin:@localhost:1521:sampledb
user: ${system.user.name}
password:
driver: oracle
history: $vars.historyDir/scrgskd
[db_access]
driver: access
url: jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=/tmp/sample.mdb;DriverID=22}
2. Add Pivotal GemFireXd client driver "gemfirexd-client.jar" to "/Applications/sqlshell/lib"
3. With Pivotal GemFireXD cluster up and running connect and run some commands as shown below.
[Mon Oct 20 11:56:10 papicella@:~/vmware/software/sqlshell ] $ sqlshell gemfirexd,jdbc:gemfirexd://localhost:1527 SQLShell, version 0.8.1 (2012/03/16 09:43:31) Copyright (c) 2009-2011 Brian M. Clapper Using JLine Type "help" for help. Type ".about" for more information. sqlshell> .set schema APP sqlshell> .show tables ALL_EMPS APPLES_OFFHEAP CUSTOMERS DEPT EMP EMPLOYEES EMPS_IN_DEPT_10 EMPS_IN_DEPT_20 EMPS_IN_DEPT_30 EMPS_IN_DEPT_40 OFFICES ORDERDETAILS ORDERS PAYMENTS PERSON PRODUCTLINES PRODUCTS TEST_ASYNC TEST_ASYNC2 TEST_CALLBACKLISTENER sqlshell> select * from dept; Execution time: 0.21 seconds Retrieval time: 0.6 seconds 7 rows returned. DEPTNO DNAME LOC ------ ---------- -------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BRISBANE 50 MARKETING ADELAIDE 60 DEV PERTH 70 SUPPORT SYDNEY sqlshell> .capture to /tmp/results.csv Capturing result sets to: /tmp/results.csv sqlshell> select * from emp where deptno = 10; Execution time: 0.18 seconds Retrieval time: 0.5 seconds 3 rows returned. EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ----- ------ --------- ---- --------------------- ---- ---- ------ 7782 CLARK MANAGER 7839 1981/06/09 00:00:00.0 2450 NULL 10 7839 KING PRESIDENT NULL 1981/11/17 00:00:00.0 5000 NULL 10 7934 MILLER CLERK 7782 1982/01/23 00:00:00.0 1300 NULL 10 sqlshell> .capture off No longer capturing query results. sqlshell>
No comments:
Post a Comment