Ben Chuanlong Du's Blog

It is never too late to learn.

Hands on the Cobra Module in Golang

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comments

  1. Cobra support groups of flags which appear together or are mutually exclusive. For detailed discussions, please refer to Flag Groups .

Quickly Start a Cobra-based project

Below is an example of creating a cobra-based project "icon".

Split String into Rows in SQL

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

split

SELECT
    A.state,
    split.A.value('.', 'VARCHAR(100)') AS String
FROM (
    SELECT 
        state,  
        CAST('<M>' + REPLACE(city, ',', '</M><M>') + '</M>' AS XML) AS string  
    FROM
        TableA
    ) AS A
CROSS APPLY String.nodes ('/M') AS split(a)

Insert or Update in SQLite3

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comments

  1. UPSERT does NOT work with virtual table in SQLite3 currently!

The UPSERT clause (following PostgreSQL syntax) is supported in SQLite 3.24.0+.

:::sql
INSERT INTO players (
    user_name, age
) VALUES (
    'steven', 32
) ON CONFLICT (user_name) DO UPDATE
SET age=excluded.age
;