小编Yus*_*fmm的帖子

表“subscriber_historization”上的唯一约束缺少作为分区键一部分的列“processing_date”

我想使用约束,以便我可以使用 upsert。因为我不想在 customer_identifier_value 上重复输入。

on conflict (customer_identifier_value) do nothing

[42P10] ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
Run Code Online (Sandbox Code Playgroud)

当我创建约束时

alter table subscriber_historization
add constraint customer_identifier_value_unique unique (customer_identifier_value);

[0A000] ERROR: insufficient columns in UNIQUE constraint definition
Detail: UNIQUE constraint on table "subscriber_historization" lacks column "processing_date" which is part of the partition key.
Run Code Online (Sandbox Code Playgroud)

这是 DDL。

-- auto-generated definition
create table subscriber_historization
(
    customer_identifier_value text not null,
    product_value             text,
    contract_date_end         date,
    processing_date           date not null,
    constraint subscriber_historization_pk
        primary …
Run Code Online (Sandbox Code Playgroud)

postgresql

4
推荐指数
1
解决办法
2208
查看次数

无法从 env 获取嵌套密钥以使用 viper 覆盖 yaml 配置文件

这是我的简化配置:

stripe:
  secret_key: sk_fromconfig
Run Code Online (Sandbox Code Playgroud)

为什么 viper 不从 env 获取值?

% echo $STRIPE_SECRET_KEY
sk_fromenv
% go run main.go 
sk_fromconfig
Run Code Online (Sandbox Code Playgroud)

我希望它从 env 中获取价值,因为我有这样的一个:

% echo $STRIPE_SECRET_KEY
sk_fromenv
% go run main.go 
sk_fromenv
Run Code Online (Sandbox Code Playgroud)

这是代码:

package main

import (
    "fmt"

    viper "github.com/spf13/viper"
)

type Config struct {
    Stripe Stripe
}

type Stripe struct {
    SecretKey string `mapstructure:"secret_key"`
}

func main() {
    viper.SetConfigName("config")
    viper.SetConfigType("yaml")
    viper.AddConfigPath(".")

    viper.AutomaticEnv()
    _ = viper.ReadInConfig()

    var config Config
    _ = viper.Unmarshal(&config)

    fmt.Println(config.Stripe.SecretKey)
}
Run Code Online (Sandbox Code Playgroud)

我尝试过viper.BindEnv("STRIPE_SECRET_KEY")viper.SetEnvPrefix("STRIPE")但没有成功。

go viper-go

3
推荐指数
1
解决办法
2439
查看次数

如何使用PHP从文本文件中删除一些行?

我有一个包含这些数据的文本文件:

947 11106620030 Ancho Khoren MKK6203简介繁忙2,00
948 balblalbllablab
949 balblalbllablab
950 balblalbllablab
951 11106620031 Adagasa Goo MKB6201 Economy Inside 3,00
952 balblalbllablab
953 balblalbllablab
954 balblalbllablab
962 11106620032 Fumiou Moon MKB6201 The Book of World 3,00

但是,我需要删除包含'balblabllablab'的所有行,并保留tge特定的数据行,如下所示:

947 11106620030安乔Khoren MKK6203简介忙2,00
951 11106620031 Adagasa咕MKB6201
经济内部3,00
世界3,00的962 11106620032的Fumiou月亮MKB6201书

我知道如何打开和写入文件以及关闭文件,但我不知道如何使用PHP删除行/内容.如何使用php从文件中删除不需要的行?

php file

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

file ×1

go ×1

php ×1

postgresql ×1

viper-go ×1