UNPKG

teradatasql

Version:
68 lines 2.55 kB
"use strict"; // Copyright 2023 by Teradata Corporation. All rights reserved. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); // This sample program demonstrates how to display the output from a show command. // The show command output includes embedded carriage returns as line terminators, // which typically must be changed to newlines in order to display properly. // The show command output may include multiple result sets, and the cursor nextset // function must be called to advance to subsequent result sets. // @ts-ignore const teradatasql = __importStar(require("teradatasql")); function ShowCommand(cur, s) { console.log("-- " + s); cur.execute(s); let n = 1; while (true) { console.log(`-- result set ${n}`); const rows = cur.fetchall(); for (const row of rows) { const s = JSON.stringify(row).split("\\r").join("\n"); console.log(s.slice(2, s.length - 2)); } if (cur.nextset()) { n += 1; } else { break; } } } const con = teradatasql.connect({ host: "whomooz", user: "guest", password: "please" }); try { const cur = con.cursor(); try { ShowCommand(cur, "show view DBC.DBCInfo"); console.log(); ShowCommand(cur, "show select * from DBC.DBCInfo"); } finally { cur.close(); } } finally { con.close(); } //# sourceMappingURL=ShowCommand.js.map