node连接PostgreSQL
来源:互联网 发布:更相减损术算法步骤 编辑:程序博客网 时间:2024/05/30 22:52
从开始一直用PostgreSQL,需要数据库的时候又把它搬到node上了,接下来就安装和简单使用步骤做一个梳理:
1,首先自己电脑上得安装PostgreSQL,附上下载地址https://www.postgresql.org/download/(安装的时候输入的密码一定要记住,数据库连接的时候要用);
2,node工程里安装“pg” ---- npm install pg ;
3,完成安装之后,进行如下操作:
const { Pool, Client } = require('pg')const pool = new Pool({ user: '一般默认为postgres,不知道的话打开数据库的connection去看', host: 'localhost', database: '这里是你的数据库表名', password: '这里是你安装数据库时候输入的密码', port: 5432,})
pool.query('select id from test', (err, ress) => { console.log(err, ress.rows);res.send({"info_name":ress.rows});pool.end()})pool.query第一个参数为数据库操作语句,附上w3c的教程链接http://www.w3school.com.cn/sql/index.asp这就是很简单的pg在node上使用的一个流程,具体复杂的以后再研究,官网上还有很多好玩的
https://node-postgres.com/
阅读全文
0 0
- node连接PostgreSQL
- Node.js 连接 postgreSQL数据库
- Node.js 连接 postgreSQL数据库 (使用连接池pool)
- Node.js中连接PostgreSql数据库的方法
- node.js访问postgresql 数据库
- node.js 操作 postgresql 数据库
- PostgreSQL的相关连接
- VC代码连接PostgreSql
- VB6连接PostgreSQL数据库
- Postgresql 客户端连接问题
- Perl 连接Postgresql
- 远程连接postgreSQL数据库
- postgresql pgadmin 连接服务器
- C连接PostgreSQL示例
- VC6连接PostgreSQL例程
- delphi 连接PostgreSQL
- Postgresql 8.3 远程连接
- Postgresql 8.3 远程连接
- J.U.C-DelayQueue原理与应用
- css3实现旋转太极图
- 初识Lucene
- eclipse中tomcat启动时项目加载两次
- 让我们从机器学习谈起(网上看到的最好的一篇入门介绍)
- node连接PostgreSQL
- dom4j的简单使用案例
- IntelliJ IDEA 设置代码提示或自动补全的快捷键
- 文件及数据流技术(四)
- Spring Boot集成JdbcTemplate的问题总结~~
- 学习进阶推荐书籍
- OpenStack高可用(HA)和灾备(DR)解决方案
- elasstic search request not sucessfully
- Java中的String为什么是不可变的? -- String源码分析