1 |
Example: fbsql |
2 |
============== |
3 |
|
4 |
fbsql is more than just a simple example and is an ISQL replacement console mode program for |
5 |
non-interactive use. fbsql uses TIBXScript as its SQL Script Engine and TIBExtract to |
6 |
extract metadata from the database. Select queries are handled by by outputing the |
7 |
query results to stdout in CSV format suitable for loading into a spreadsheet. |
8 |
|
9 |
Usage: fbsql <options> <database name> |
10 |
Options: |
11 |
-a write database metadata to stdout |
12 |
-b stop on first error |
13 |
-e echo sql statements to stdout |
14 |
-f <filename> execute SQL script from file |
15 |
-h show this information |
16 |
-p <password> provide password on command line (insecure) |
17 |
-r <rolename> open database with this rolename |
18 |
-s <sql> Execute SQL text |
19 |
-u <username> open database with this username (defaults to SYSDBA) |
20 |
|
21 |
Environment Variables: |
22 |
ISC_USER Login user Name |
23 |
ISC_PASSWORD Login password |
24 |
|
25 |
Saving the username and/or password as environment variables avoids having to enter |
26 |
them on the command line and is a more secure means of provding the password. |
27 |
|
28 |
fbsql uses IBX in console mode. Before opening this project you should tell the Lazarus |
29 |
IDE about the ibexpressconsolemode package. All you need to do in the IDE is to select "Packages->Open Package File" |
30 |
and open ibexpressconsolemode.lpk which you can find in the ibx root directory. You should then close it again |
31 |
immediately afterwards. There is no need to install or compile it. Opening the package is sufficient for Lazarus to |
32 |
remember it. |
33 |
|
34 |
To use, compile the program in the Lazarus IDE and run it from the command line. The |
35 |
above gives the command line parameters. For example: |
36 |
|
37 |
fbsql -a -u SYSDBA -p masterkey employee |
38 |
|
39 |
will write out the metadata for the local employee database to stdout (assuming |
40 |
default password). |
41 |
|
42 |
fbsql -s "Select * From EMPLOYEE" -u SYSDBA -p masterkey employee |
43 |
|
44 |
will write out the contents of the EMPLOYEE table in the local employee database to stdout (assuming |
45 |
default password). |
46 |
|
47 |
fbsql -b -e ../scriptengine/tests/CreateCountriesTable.sql -u SYSDBA -p masterkey employee |
48 |
|
49 |
will run the script CreateCountriesTable.sql from the script engine test suite and apply |
50 |
it to the local employee database. Each statement will be echoed to stdout and |
51 |
processing will stop on the first error. |
52 |
|
53 |
Note that on Linux, to run a program from the command line that is not on the PATH, |
54 |
you need to: |
55 |
|
56 |
cd to the example directory "ibx/examples/fbsql" |
57 |
run the program as "./fbsql" e.g. |
58 |
|
59 |
./fbsql -a -u SYSDBA -p masterkey employee |
60 |
|
61 |
|