In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of what database node can use, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this node article on what database you can use. Let's take a look at it.
The databases that node can use are: 1, IBM DB2;2, MS SQL Server;3, PostgreSQL;4, MySQL;5, SQLite;6, Oracle;7, Mongo;8, Hive;9, Redis;10, CouchDB and so on.
This tutorial operating environment: windows7 system, nodejs version 12.19.0, DELL G3 computer.
Node.js is a development platform that allows JavaScript to run on the server, which can be used to build network applications with fast response and easy to expand. Node uses event-driven, non-blocking Istroke O model to make it lightweight and efficient, which is very suitable for running data-intensive real-time applications on distributed devices.
Node.js supports the following Database:
IBM DB2
MS SQL Server
PostgreSQL
MySQL
SQLite
Oracle
NoSQL and Key/Value
Mongo
Hive
Redis
CouchDB
Other NoSQL implementations
So how do you choose?
What node uses as a database depends on the business scenario. Mainstream databases can be selected. Generally speaking, mysql is more commonly used in the industry.
There are many nodejs + Oracle pits, but it can be done.
Nodejs + Mysql is used by the most people. After all, mysql is already very popular.
Nodejs + mongodb Fast + Fast = very fast, suitable for ultra-fast development mode.
Example: Node.js connects to MySQL database
1. Install the driver
The cnpm command customized by Taobao is used to install:
$cnpm install mysql
2. Connect to the database
Modify the database user name, password and database name according to your actual configuration in the following example:
Test.js file code:
Var mysql = require ('mysql'); var connection = mysql.createConnection ({host:' localhost', user: 'root', password:' 123456, database: 'test'}); connection.connect (); connection.query (' SELECT 1 + 1 AS solution', function (error, results, fields) {if (error) throw error; console.log ('The solution is:', results [0] .solution);})
Execute the following command to output the following:
$node test.jsThe solution is: 2
Description of database connection parameters:
Parameter description host host address (default: localhost) user user name password password port port number (default: 3306) database database name charset connection character set (default: 'UTF8_GENERAL_CI', note that all letters in the character set should be uppercase) localAddress this IP is used for TCP connections (optional) socketPath connection to unix domain path Timezone time zone (default: 'local') connectTimeout connection timeout (default: no limit) is ignored when using host and port (in milliseconds) whether stringifyObjects serializes objects typeCast converts column values to local JavaScript type values (default: true) queryFormat custom query statement formatting method supportBigNumbers database supports bigint or decimal type columns You need to set this option to true (default: false) bigNumberStringssupportBigNumbers and bigNumberStrings to enable force bigint or decimal columns to return as JavaScript string type (default: false) dateStrings force timestamp,datetime,data type to return as string type Instead of JavaScript Date type (default: false) debug enables debugging (default: false) whether multipleStatements allows multiple MySQL statements in a query (default: false) flags is used to modify the connection flag ssl uses the ssl parameter (one to the format of the crypto.createCredenitals parameter) or a string containing the name of the ssl configuration file At present, it is only bundled with the configuration file of Amazon RDS. This is the end of the article on "what databases can node use?" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what database can be used by node". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.