{"analyzedAt":"2023-01-05T21:21:16.278Z","collected":{"metadata":{"name":"@sap/hana-client","scope":"sap","version":"2.15.19","description":"Official SAP HANA Node.js Driver","keywords":["SAP","HANA","client","in-memory","database","SQL","business","application","intelligent","enterprise","cloud","analytics","experience"],"date":"2023-01-05T21:20:54.893Z","author":{"name":"SAP SE"},"publisher":{"username":"sap_extncrepos","email":"mob.extrepo.stores@sap.com"},"maintainers":[{"username":"sap_extncrepos","email":"mob.extrepo.stores@sap.com"}],"links":{"npm":"https://www.npmjs.com/package/%40sap%2Fhana-client"},"dependencies":{"debug":"3.1.0"},"releases":[{"from":"2022-12-06T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":2},{"from":"2022-10-07T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":4},{"from":"2022-07-09T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":6},{"from":"2022-01-05T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":13},{"from":"2021-01-05T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":27}],"readme":"# @sap/hana-client\r\n\r\nFully-featured Node.js driver for [SAP HANA](https://www.sap.com/products/hana.html). It is used to connect, issue SQL queries, and obtain result sets.\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install @sap/hana-client\r\n```\r\n\r\n## Prerequisites\r\n\r\nThis driver communicates with the native HANA libraries, and thus requires\r\nplatform-specific native binaries. The official hosted version includes\r\nprecompiled libraries for Linux, Windows and Mac OS X.\r\n\r\nThe @sap/hana-client driver supports versions of Node.js 10 and higher.\r\n\r\n## Community\r\n\r\nSAP Community provides a forum where you can ask and answer questions, and\r\ncomment and vote on the questions of others and their answers.\r\n\r\nSee [SAP HANA Community Questions](https://answers.sap.com/tags/73554900100700000996) for details.\r\n\r\n## Help Guide\r\n\r\nThe SAP HANA Node.js Driver help guide and API reference can be found on [help.sap.com](https://help.sap.com/viewer/f1b440ded6144a54ada97ff95dac7adf/latest/en-US/a5c332936d9f47d8b820a4ecc427352c.html).\r\n\r\n## Getting Started\r\n\r\n```js\r\nvar hana = require('@sap/hana-client');\r\n\r\nvar conn = hana.createConnection();\r\n\r\nvar conn_params = {\r\n  serverNode  : 'myserver:30015',\r\n  uid         : 'system',\r\n  pwd         : 'Password123'\r\n};\r\n\r\nconn.connect(conn_params, function(err) {\r\n  if (err) throw err;\r\n  conn.exec('SELECT Name, Description FROM Products WHERE id = ?', [301], function (err, result) {\r\n    if (err) throw err;\r\n\r\n    console.log('Name: ', result[0].Name, ', Description: ', result[0].Description);\r\n    // output --> Name: Tee Shirt, Description: V-neck\r\n    conn.disconnect();\r\n  })\r\n});\r\n```\r\n\r\n## Establish a database connection\r\n\r\n### Connecting\r\n\r\nA database connection object is created by calling `createConnection`.  The\r\nconnection is established by calling the connection object's `connect` method,\r\nand passing in an object representing connection parameters.\r\n\r\n#### Example: Connecting over TCP/IP\r\n\r\n```js\r\nconn.connect({\r\n  host    : 'myserver',\r\n  port    : '30015',\r\n  uid     : 'system',\r\n  pwd     : 'Password123'\r\n});\r\n```\r\n\r\n### Disconnecting\r\n\r\n```js\r\nconn.disconnect(function(err) {\r\n  if (err) throw err;\r\n  console.log('Disconnected');\r\n});\r\n```\r\n\r\n## Direct Statement Execution\r\n\r\nDirect statement execution is the simplest way to execute SQL statements. The\r\ninputs are the SQL command to be executed, and an optional array of positional\r\narguments. The result is returned using callbacks. The type of returned result\r\ndepends on the kind of statement.\r\n\r\n### DDL Statement\r\n\r\nIn the case of a successful DDL Statement, nothing is returned.\r\n\r\n```js\r\nconn.exec('CREATE TABLE Test (id INTEGER PRIMARY KEY, msg VARCHAR(128))', function (err, result) {\r\n  if (err) throw err;\r\n  console.log('Table Test created!');\r\n});\r\n```\r\n\r\n### DML Statement\r\n\r\nIn the case of a DML Statement the number of `affectedRows` is returned.\r\n\r\n```js\r\nconn.exec(\"INSERT INTO Test VALUES(1, 'Hello')\", function (err, affectedRows) {\r\n  if (err) throw err;\r\n  console.log('Number of affected rows:', affectedRows);\r\n});\r\n```\r\n\r\n### Query\r\n\r\nThe `exec` function is a convenient way to completely retrieve the result of a\r\nquery. In this case all selected rows are fetched and returned in the callback.\r\n\r\n```js\r\nconn.exec(\"SELECT * FROM Test WHERE id < 5\", function (err, rows) {\r\n  if (err) throw err;\r\n  console.log('Rows:', rows);\r\n});\r\n```\r\n\r\nValues in the query can be substitued with JavaScript variables by using `?`\r\nplaceholders in the query, and passing an array of positional arguments.\r\n\r\n```js\r\nconn.exec(\"SELECT * FROM Test WHERE id BETWEEN ? AND ?\", [5, 8], function (err, rows) {\r\n  if (err) throw err;\r\n  console.log('Rows:', rows);\r\n});\r\n```\r\n\r\n## Prepared Statement Execution\r\n\r\n### Prepare a Statement\r\n\r\nThe connection returns a `statement` object which can be executed multiple times.\r\n\r\n```js\r\nconn.prepare('SELECT * FROM Test WHERE id = ?', function (err, stmt){\r\n  if (err) throw err;\r\n  // do something with the statement\r\n});\r\n```\r\n\r\n### Execute a Statement\r\n\r\nThe execution of a prepared statement is similar to the direct statement execution.\r\nThe first parameter of `exec` function is an array with positional parameters.\r\n\r\n```js\r\nstmt.exec([16], function(err, rows) {\r\n  if (err) throw err;\r\n  console.log(\"Rows: \", rows);\r\n});\r\n```\r\n\r\n### Execute a Batch Statement\r\n\r\nThe execution of a prepared batch statement is similar to the direct statement execution.\r\nThe first parameter of `execBatch` function is an array with positional parameters.\r\n\r\n```js\r\nvar stmt=conn.prepare(\"INSERT INTO Customers(ID, NAME) VALUES(?, ?)\");\r\nstmt.execBatch([[1, 'Company 1'], [2, 'Company 2']], function(err, rows) {\r\n  if (err) throw err;\r\n  console.log(\"Rows: \", rows);\r\n});\r\n```\r\n\r\n### Execute a Query\r\n\r\nThe execution of a prepared query is similar to the direct statement execution.\r\nThe first parameter of `execQuery` function is an array with positional parameters.\r\n\r\n```js\r\nvar stmt=conn.prepare(\"SELECT * FROM Customers WHERE ID >= ? AND ID < ?\");\r\nstmt.execQuery([100, 200], function(err, rs) {\r\n  if (err) throw err;\r\n    var rows = [];\r\n    while (rs.next()) {\r\n      rows.push(rs.getValues());\r\n    }\r\n  console.log(\"Rows: \", rows);\r\n});\r\n```\r\n\r\n### Drop Statement\r\n\r\n```js\r\nstmt.drop(function(err) {\r\n  if (err) throw err;\r\n});\r\n```\r\n\r\n## Transaction Handling\r\n\r\n__Transactions are automatically commited.__ Setting autocommit to false implicitly\r\nstarts a new transaction that must be explicitly committed, or rolled back.\r\n\r\n### Commit a Transaction\r\n\r\n```js\r\nconn.setAutoCommit(false);\r\n// Execute some statements\r\nconn.commit(function(err) {\r\n  if (err) throw err;\r\n  console.log('Transaction commited.');\r\n});\r\n```\r\n\r\n### Rollback a Transaction\r\n\r\n```js\r\nconn.setAutoCommit(false);\r\n// Execute some statements\r\nconn.rollback(function(err) {\r\n  if (err) throw err;\r\n  console.log('Transaction rolled back.');\r\n});\r\n```\r\n\r\n## Resources\r\n\r\n+ [SAP HANA Documentation](https://help.sap.com/viewer/f1b440ded6144a54ada97ff95dac7adf/latest/en-US/a5c332936d9f47d8b820a4ecc427352c.html)"},"npm":{"downloads":[{"from":"2023-01-04T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":16810},{"from":"2022-12-29T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":72454},{"from":"2022-12-06T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":395742},{"from":"2022-10-07T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":1230358},{"from":"2022-07-09T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":2062009},{"from":"2022-01-05T00:00:00.000Z","to":"2023-01-05T00:00:00.000Z","count":3610103}],"starsCount":0},"source":{"files":{"readmeSize":6047,"testsSize":0,"hasShrinkwrap":true,"hasChangelog":true},"outdatedDependencies":{"debug":{"required":"3.1.0","stable":"4.3.4","latest":"4.3.4"}}}},"evaluation":{"quality":{"carefulness":0.46,"tests":0,"health":0.75,"branding":0},"popularity":{"communityInterest":0,"downloadsCount":410119.3333333333,"downloadsAcceleration":1216.4048135464227,"dependentsCount":0},"maintenance":{"releasesFrequency":1,"commitsFrequency":0,"openIssues":0,"issuesDistribution":0}},"score":{"final":0.29748476759678866,"detail":{"quality":0.44812786352026723,"popularity":0.13251354821154815,"maintenance":0.3333333333333333}}}