草庐IT

postgresql-9.6

全部标签

postgresql - Golang 记录 ID 为 0

我有以下Car模型和一个carsslice:typeCarstruct{IDint`json:"id"`Namestring`json:"title"`}varcars[]Car在Postgres数据库上,我创建了一个cars表来保存car记录。createtablecars(idserial,namevarchar);并保存了一些汽车记录:insertintocars(name)values('Toyota');insertintocars(name)values('Lexus');记录已成功创建,增量整数ID为1和2。在我的Go服务器中,我进行以下查询以获取汽车记录:db.Quer

postgresql - Golang 记录 ID 为 0

我有以下Car模型和一个carsslice:typeCarstruct{IDint`json:"id"`Namestring`json:"title"`}varcars[]Car在Postgres数据库上,我创建了一个cars表来保存car记录。createtablecars(idserial,namevarchar);并保存了一些汽车记录:insertintocars(name)values('Toyota');insertintocars(name)values('Lexus');记录已成功创建,增量整数ID为1和2。在我的Go服务器中,我进行以下查询以获取汽车记录:db.Quer

postgresql - Postgres 在数据库 : Could not detect default username 上运行查询时出错

您好,我正在尝试使用Prometheus监控postgresSQL。为此,我正在使用这个导出商https://github.com/wrouesnel/postgres_exporter我在我的docker-compose.yml中启动导出器,如下所示:exporter-postgres:image:wrouesnel/postgres_exporterports:-9113:9113environment:-DATA_SOURCE_NAME="postgresql://user:pass@localhost:5432/?sslmode=disable"当导出器尝试访问数据库时会抛出这

postgresql - Postgres 在数据库 : Could not detect default username 上运行查询时出错

您好,我正在尝试使用Prometheus监控postgresSQL。为此,我正在使用这个导出商https://github.com/wrouesnel/postgres_exporter我在我的docker-compose.yml中启动导出器,如下所示:exporter-postgres:image:wrouesnel/postgres_exporterports:-9113:9113environment:-DATA_SOURCE_NAME="postgresql://user:pass@localhost:5432/?sslmode=disable"当导出器尝试访问数据库时会抛出这

postgresql - 与 postgreSQL 模式连接

我希望连接并查询PostgreSQL。但我只想连接到特定的Schema.根据文档(JDBC)我们可以使用jdbc:postgresql://localhost:5432/mydatabase?searchpath=myschema或更新从9.4开始,您可以使用新的currentSchema参数指定url,如下所示:jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema但我无法使用golangSQL驱动程序这样做;根据文档,我们还可以使用SETsearch_pathTOmyschema,public;但我只想在

postgresql - 与 postgreSQL 模式连接

我希望连接并查询PostgreSQL。但我只想连接到特定的Schema.根据文档(JDBC)我们可以使用jdbc:postgresql://localhost:5432/mydatabase?searchpath=myschema或更新从9.4开始,您可以使用新的currentSchema参数指定url,如下所示:jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema但我无法使用golangSQL驱动程序这样做;根据文档,我们还可以使用SETsearch_pathTOmyschema,public;但我只想在

postgresql - 如何在 Postgresql 时间戳中存储 Golang time.time?

我可以知道如何在Postgresql中存储time.time对象吗?例如SQL查询:INSERTINTO"UserAccount"("email","login_time")VALUES('human@example.com',2017-12-1200:58:26.9589451+0800+08m=+1406.914186601)我尝试使用loginTime:=time.Now(),它给出了Postgresql并不真正理解的时间格式,例如2017-12-1200:58:26.9589451+0800+08m=+1406.914186601但是如果我尝试使用loginTime:=time

postgresql - 如何在 Postgresql 时间戳中存储 Golang time.time?

我可以知道如何在Postgresql中存储time.time对象吗?例如SQL查询:INSERTINTO"UserAccount"("email","login_time")VALUES('human@example.com',2017-12-1200:58:26.9589451+0800+08m=+1406.914186601)我尝试使用loginTime:=time.Now(),它给出了Postgresql并不真正理解的时间格式,例如2017-12-1200:58:26.9589451+0800+08m=+1406.914186601但是如果我尝试使用loginTime:=time

postgresql - 如何用Beego制作API测试文件

我有以下测试文件:packagetestsimport("net/http""net/http/httptest""testing""runtime""path/filepath"_"hello/routers"_"github.com/lib/pq""github.com/astaxie/beego"."github.com/smartystreets/goconvey/convey")funcinit(){_,file,_,_:=runtime.Caller(1)apppath,_:=filepath.Abs(filepath.Dir(filepath.Join(file,".."

postgresql - 如何用Beego制作API测试文件

我有以下测试文件:packagetestsimport("net/http""net/http/httptest""testing""runtime""path/filepath"_"hello/routers"_"github.com/lib/pq""github.com/astaxie/beego"."github.com/smartystreets/goconvey/convey")funcinit(){_,file,_,_:=runtime.Caller(1)apppath,_:=filepath.Abs(filepath.Dir(filepath.Join(file,".."