SQLite 命令行客户端 + HTA 实现简易UI

SQLite 命令行客户端 + HTA 实现简易UI

仅用于探索可行性,就只实现了 SELECT

SQLite 客户端.hta

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<HTA:APPLICATION
	  APPLICATIONNAME="Demo"
	  ID="JerryHTA"
	  VERSION="1.0"
	  ICON=""
	  BORDER="dialog"
	  SCROLL="no"
	  SINGLEINSTANCE="yes"
	  CONTEXTMENU="yes"
	  NAVIGABLE="yes"/>
	<meta http-equiv="x-ua-compatible" content="ie=edge"/>

	
    <title>SQLite 客户端 - HTA 版</title>
    <style>
        body { font-family: Arial, sans-serif; }
        #cmdResult { white-space: pre-wrap; }
		
		/* 表格样式 */
		table {
			width: 100%;
			border-collapse: collapse;
			margin-top: 20px;
		}

		table th,
		table td {
			border: 1px solid #ddd;
			padding: 8px;
			text-align: left;
		}

		/* 表头样式 */
		tabl thead th {
			background-color: #007BFF;
			color: white;
			font-weight: bold;
			text-transform: uppercase;
		}

		/* 鼠标悬停效果 */
		table tbody tr:hover {
			background-color: #f5f5f5;
		}

		/* 交替行颜色 */
		table tbody tr:nth-child(even) {
			background-color: #f2f2f2;
		}
    </style>
    <script language="JScript">

        function runCmd() {
            var cmd = document.getElementById('cmdInput').value;
            try {
                var shell = new ActiveXObject("WScript.Shell");
				var sqlCmd = 'sqlite3.exe MY_DB.db ".mode html" ".headers on" ".width auto" "'+ cmd + '"';
				var encodingCmd = 'cmd /C CHCP 65001 > nul & ' + sqlCmd;
				var exec = shell.Exec(encodingCmd);

				while (exec.Status == 0){}
			
				var Stream = new ActiveXObject("ADODB.Stream");
				Stream.Open();
				Stream.Type = 2; // Text type
				Stream.Charset = "UTF-8";
				// 直接从文件读取数据,确保编码正确
				Stream.LoadFromFile('sqltemp');

				// 读取所有数据
				var result = Stream.ReadText(-1);
				Stream.Close();

                // 清除之前的输出并显示新结果
                document.getElementById('cmdResult').innerHTML = '<table>' + result + '</table>';
            } catch (e) {
                document.getElementById('cmdResult').innerText = "Error: " + e.message;
            }
        }
    </script>
</head>
<body>
    <h1>SQLite 客户端</h1>
    <textarea id="cmdInput" rows="5" cols="60">SELECT * FROM 订单表;</textarea><br/>
    <button onclick="runCmd()">执行</button>
    <hr/>
    <h2>执行结果</h2>
    <pre id="cmdResult"></pre>
</body>
</html>

目录结构

在这里插入图片描述

参考资料

笑虾:SQLite 命令行客户端 + Windows 批处理应用
VBScript Scripting Techniques > HTAs
HTA & WSC Examples
599cd:HTA Tips

相关推荐

  1. 手写实现简单Redis命令客户功能

    2024-07-10 10:26:05       19 阅读
  2. Docker客户命令

    2024-07-10 10:26:05       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 10:26:05       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 10:26:05       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 10:26:05       90 阅读
  4. Python语言-面向对象

    2024-07-10 10:26:05       98 阅读

热门阅读

  1. Linux内核 -- 内存管理之scatterlist结构使用

    2024-07-10 10:26:05       52 阅读
  2. 【国产开源可视化引擎Meta2d.js】数据

    2024-07-10 10:26:05       28 阅读
  3. Elasticsearch 面试题指南

    2024-07-10 10:26:05       26 阅读
  4. Linux笔记之iftop查看特定IP地址吞吐量

    2024-07-10 10:26:05       23 阅读
  5. 量化交易在不同经济周期中的表现

    2024-07-10 10:26:05       29 阅读
  6. Kotlin构造函数

    2024-07-10 10:26:05       31 阅读
  7. 生日判断星座【GO】

    2024-07-10 10:26:05       26 阅读
  8. SQL Server设置端口:跨平台指南

    2024-07-10 10:26:05       26 阅读
  9. 指定版本ceph-common安装

    2024-07-10 10:26:05       29 阅读
  10. 中科海讯 C++初级研发工程师笔试题目

    2024-07-10 10:26:05       36 阅读
  11. vue3的常用 Composition API有哪些?

    2024-07-10 10:26:05       26 阅读