草庐IT

postgresql-9.6

全部标签

postgresql - 如何在 Docker 容器之间建立连接

当我尝试将我的goLangGORM服务连接到DockerPostgress容器时遇到连接问题。我认为问题出在连接字符串底部的golang代码上。docker-composeupRecreatingpostgress_postgre_1...doneAttachingtopostgrespostgres|2018-12-1121:08:48.283UTC[1]LOG:listeningonIPv4address"0.0.0.0",port5432postgres|2018-12-1121:08:48.283UTC[1]LOG:listeningonIPv6address"::",port

postgresql - COALESCE 在 Postgres 中返回文本类型而不是 time_stamp 类型

我正在尝试使用COALESCE来处理Go中的sql注入(inject)。query:=`SELECTmc.company_name_full,msc.company_id,msc.cdate,%sFROM%sASmcINNERJOIN%sASmscON(mc.id=msc.company_id)WHERE%sANDmsc.company_id=COALESCE($1,msc.company_id)ANDmc.company_name_full~*COALESCE($2,mc.company_name_full)ANDmsc.cdate>='2017-07-01'ANDmsc.cdate

postgresql - COALESCE 在 Postgres 中返回文本类型而不是 time_stamp 类型

我正在尝试使用COALESCE来处理Go中的sql注入(inject)。query:=`SELECTmc.company_name_full,msc.company_id,msc.cdate,%sFROM%sASmcINNERJOIN%sASmscON(mc.id=msc.company_id)WHERE%sANDmsc.company_id=COALESCE($1,msc.company_id)ANDmc.company_name_full~*COALESCE($2,mc.company_name_full)ANDmsc.cdate>='2017-07-01'ANDmsc.cdate

源码编译安装POSTGRESQL15

添加用户useraddpostgrespasswdpostgresmkdir-p/app/postgresql/{data,log}chown-Rpostgres:postgres/app/postgresql安装依赖包yum-yinstallncurses-develreadline-develzlibzlib-develperl-ExtUtils-Embed安装./Anaconda3-2021.11-Linux-x86_64.sh配置环境变量su-postgresexportMYSQL_HOME=/app/mysqlexportANACONDA_HOME=/app/anaconda3exp

postgresql - postgres 准备查询,列作为变量

varSelectUser,_=Database.Prepare("SELECT$1FROMusersWHEREid=$2LIMIT1;")varnamestringSelectUser.QueryRow("name",1).Scan(&name)如果我这样做,我会得到一个错误:runtimeerror:invalidmemoryaddressornilpointerdereference但是如果column不是可变的,就没问题。varSelectUser,_=Database.Prepare("SELECTnameFROMusersWHEREid=$1LIMIT1;")varname

postgresql - postgres 准备查询,列作为变量

varSelectUser,_=Database.Prepare("SELECT$1FROMusersWHEREid=$2LIMIT1;")varnamestringSelectUser.QueryRow("name",1).Scan(&name)如果我这样做,我会得到一个错误:runtimeerror:invalidmemoryaddressornilpointerdereference但是如果column不是可变的,就没问题。varSelectUser,_=Database.Prepare("SELECTnameFROMusersWHEREid=$1LIMIT1;")varname

postgresql - 从 golang 查询 Postgres 复合类型

所以我正在使用go-gorp来查询postgres,但我似乎无法查询我的表中的复合类型,这是一个错误。我想要的只是适当嵌套的JSON响应。我的postgres模式是:CREATETYPEPhoneTypeASENUM('MOBILE','HOME','WORK');CREATETYPEPhoneNumberAS("Number"VARCHAR,"Type"PhoneType);CREATETABLEPerson("Id"SERIALPRIMARYKEYNOTNULL,"Name"VARCHARNOTNULL,"Email"VARCHAR,"Number"PhoneNumber[]);对

postgresql - 从 golang 查询 Postgres 复合类型

所以我正在使用go-gorp来查询postgres,但我似乎无法查询我的表中的复合类型,这是一个错误。我想要的只是适当嵌套的JSON响应。我的postgres模式是:CREATETYPEPhoneTypeASENUM('MOBILE','HOME','WORK');CREATETYPEPhoneNumberAS("Number"VARCHAR,"Type"PhoneType);CREATETABLEPerson("Id"SERIALPRIMARYKEYNOTNULL,"Name"VARCHARNOTNULL,"Email"VARCHAR,"Number"PhoneNumber[]);对

postgresql - 如何在 golang 中使用 mattes/migrate?

我一直在尝试使用mattes/migrate包,但我似乎无法让它真正做任何事情。数据库在postgres上运行,我通过sqlx与它交互.我已经阅读了github上的自述文件,并应用了以下代码://usesynchronousversionsofmigrationfunctions...allErrors,ok:=migrate.UpSync("postgres://","./app/database/migrations")if!ok{fmt.Println("Ohno...")//dosthwithallErrorsslice}我的架构是这样启动的://sqlx'sinitiated

postgresql - 如何在 golang 中使用 mattes/migrate?

我一直在尝试使用mattes/migrate包,但我似乎无法让它真正做任何事情。数据库在postgres上运行,我通过sqlx与它交互.我已经阅读了github上的自述文件,并应用了以下代码://usesynchronousversionsofmigrationfunctions...allErrors,ok:=migrate.UpSync("postgres://","./app/database/migrations")if!ok{fmt.Println("Ohno...")//dosthwithallErrorsslice}我的架构是这样启动的://sqlx'sinitiated