首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未明错误:不支持的操作: postgresql中的套接字构造函数

未明错误:不支持的操作: postgresql中的套接字构造函数
EN

Stack Overflow用户
提问于 2016-01-05 05:51:36
回答 1查看 3.6K关注 0票数 2

我正在尝试将dart连接到数据库(可选的如postgrelsql、mongodb)。我安装了postgresql,并创建了db、table和goto pubspec.yaml,然后添加相关性postgresql并运行pub get。然后我提到了库文件

代码语言:javascript
复制
import 'package:postgresql/postgresql.dart';

连接细节

代码语言:javascript
复制
  var uri = 'postgres://postgres:root@localhost:5432/testdb';
   connect(uri).then((conn) {  
   }); 

但是我发现了一些我无法理解的错误。请帮帮我。

代码语言:javascript
复制
Stack Trace:

Uncaught Uncaught Error: Unsupported operation: Socket constructor

堆栈跟踪:不支持的操作: dart.wrapException (http://localhost:8080/dbconnection.dart.js:2531:15) at null.Socket_connect (http://localhost:8080/dbconnection.dart.js:11612:13) at dart.Socket_connect as call$2 at dart.Socket_connect (http://localhost:8080/dbconnection.dart.js:13515:28) at dart.Future_Future$sync (http://localhost:8080/dbconnection.dart.js:4723:28) at http://localhost:8080/dbconnection.dart.js:13468:18 (http://localhost:8080/dbconnection.dart.js:13468:18) at dart.connect (http://localhost:8080/dbconnection.dart.js:12861:14) at dart.PostgrelSqlconn (http://localhost:8080/dbconnection.dart.js:12836:7)_wrapJsFunctionForAsync_closure.dart._wrapJsFunctionForAsync 1 (http://localhost:8080/dbconnection.dart.js:2531)的main (http://localhost:8080/dbconnection.dart.js:12825:15)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-05 06:01:59

看起来您正在尝试在浏览器中运行这段代码。Postgresql在浏览器中无法工作。Mongodb确实有一个HTTP,它允许直接从浏览器中运行的代码访问它。通常,数据库访问由运行在服务器上的服务处理,浏览器向该服务发送命令以存储和检索数据,并将请求转发给数据库。或者,您也可以使用即插即用的服务器,如Firebase。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34605037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档