Default repository for execsql.py
Révision | ef3f0914a4bd9e8367c8c4fd2b1866565fdc674d (tree) |
---|---|
l'heure | 2016-02-14 05:32:40 |
Auteur | Dreas Nielsen <dreas.nielsen@gmai...> |
Commiter | Dreas Nielsen |
Added , , , and system variables.
@@ -6,7 +6,7 @@ | ||
6 | 6 | <meta name="description" content="Documentation for execsql.py, a scripting client for PostgreSQL, SQL Server, MS-Access, SQLite, MariaDB, MySQL, and Firebird databases." /> |
7 | 7 | <meta name="author" content="R. Dreas Nielsen" /> |
8 | 8 | <meta name="created" content="2008-04-27" /> |
9 | -<meta name="revised" content="2016-02-06" /> | |
9 | +<meta name="revised" content="2016-02-13" /> | |
10 | 10 | <meta name="copyright" content="Copyright (c) 2015, 2016, R. Dreas Nielsen" /> |
11 | 11 | <style type="text/css"> |
12 | 12 | html, body { |
@@ -1106,6 +1106,25 @@ | ||
1106 | 1106 | versions to directory names or file names. See |
1107 | 1107 | <a href="#example8">Example 8</a> for an illustration of its use.</dd> |
1108 | 1108 | |
1109 | +<dt class="normal">$DB_NAME</dt><dd>The name of the database currently in | |
1110 | +use, as specified on the command line or in a <a href="#connect">CONNECT</a> | |
1111 | +metacommand. This will be the database name for server-based databases, | |
1112 | +and the file name for file-based databases.</dd> | |
1113 | + | |
1114 | +<dt class="normal">$DB_NEED_PWD</dt><dd>A string equal to "TRUE" or "FALSE" | |
1115 | +indicating whether or not a password was required for the database | |
1116 | +currently in use.</dd> | |
1117 | + | |
1118 | +<dt class="normal">$DB_SERVER</dt><dd>The name of the database server | |
1119 | +for the database currently in use, as specified on the command line or | |
1120 | +in a <a href="#connect">CONNECT</a> metacommand. If the database in use | |
1121 | +is not server-based, the result will be an empty string.</dd> | |
1122 | + | |
1123 | +<dt class="normal">$DB_USER</dt><dd>The name of the database user for the | |
1124 | +database currently in use, as specified on the command line or in a | |
1125 | +<a href="#connect">CONNECT</a> metacommand. If the database connection | |
1126 | +does not require a user name, the result will be an empty string.</dd> | |
1127 | + | |
1109 | 1128 | <dt class="normal">$ERROR_HALT_STATE</dt><dd>The value of the status |
1110 | 1129 | flag that is set by the <a href="#errorhalt">ERROR_HALT</a> |
1111 | 1130 | metacommand. The value of this variable is always either "ON" or |
@@ -27,7 +27,7 @@ | ||
27 | 27 | # |
28 | 28 | # =============================================================================== |
29 | 29 | |
30 | -__version__ = "1.2.14.3" | |
30 | +__version__ = "1.2.15.0" | |
31 | 31 | _vdate = "2016-02-13" |
32 | 32 | |
33 | 33 | import os.path |
@@ -2505,6 +2505,8 @@ | ||
2505 | 2505 | self.type = dbt_sqlite |
2506 | 2506 | self.server_name = None |
2507 | 2507 | self.db_name = SQLite_fn |
2508 | + self.user = None | |
2509 | + self.need_passwd = False | |
2508 | 2510 | self.encoding = 'UTF-8' |
2509 | 2511 | self.paramstr = '?' |
2510 | 2512 | self.conn = None |
@@ -3630,6 +3632,10 @@ | ||
3630 | 3632 | self.subvars.add_substitution("$CURRENT_DIR", os.path.abspath(os.path.curdir)) |
3631 | 3633 | self.subvars.add_substitution("$AUTOCOMMIT_STATE", "ON" if dbs.current().autocommit else "OFF") |
3632 | 3634 | self.subvars.add_substitution("$TIMER", unicode(datetime.timedelta(seconds=timer.elapsed()))) |
3635 | + self.subvars.add_substitution("$DB_USER", dbs.current().user if dbs.current().user else '') | |
3636 | + self.subvars.add_substitution("$DB_SERVER", dbs.current().server_name if dbs.current().server_name else '') | |
3637 | + self.subvars.add_substitution("$DB_NAME", dbs.current().db_name) | |
3638 | + self.subvars.add_substitution("$DB_NEED_PWD", "TRUE" if dbs.current().need_passwd else "FALSE") | |
3633 | 3639 | while True: |
3634 | 3640 | match_found = False |
3635 | 3641 | cmditem.sql, match_found = self.subvars.substitute(cmditem.sql) |