반응형

https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id

 

PostgreSQL function for last inserted ID

In PostgreSQL, how do I get the last id inserted into a table? In MS SQL there is SCOPE_IDENTITY(). Please do not advise me to use something like this: select max(id) from table

stackoverflow.com

  INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John');
  SELECT currval('persons_id_seq')
  INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John');
  SELECT currval(pg_get_serial_sequence('persons','id'));

'프로그래밍' 카테고리의 다른 글

wsl2 고정 ip처럼 사용하기  (0) 2022.12.06
docker network mode  (0) 2022.12.06
이번에 작업한 도커파일  (0) 2022.11.28
golang docker 말기  (0) 2022.11.24
golang 공유 자원 사용하기  (0) 2022.11.03
반응형

golang을 최소 설치를 했더니 귀찮다.

FROM golang:alpine

WORKDIR /app

COPY . ./

RUN go mod download
RUN go mod tidy
RUN go build -o main .

# TimeZone 설정
RUN apk --no-cache add tzdata && \
    cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
    echo "Asia/Seoul" > /etc/timezone \
    apk del tzdata

CMD ["./main", "1"]
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out


# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .

# TimeZone 설정
ENV TZ Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


ENTRYPOINT ["dotnet", "AnomalyDetection.dll"]
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .

# TimeZone 설정
ENV TZ Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


ENTRYPOINT ["dotnet", "Aru.dll"]
version: '3.3'
services:
  aru_collector:
    image: 'aru_collector'
    volumes:
    - /mnt/d/Data/Aru:/var/pos
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    links:
    - "PostgreSQL"
  aru_anomaly_detection:
    image: 'aru_anomaly_detection'
    volumes:
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    links:
    - "PostgreSQL"  
  aru:
    image: 'aru'
    volumes:
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    network_mode: "host"
  PostgreSQL:
    image: postgres
    environment:
      POSTGRES_PASSWORD: "test"          
    ports:
    - 5432:5432
    volumes:
    - /home/postgreSQL:/var/lib/postgresql/data
    shm_size: 1g

'프로그래밍' 카테고리의 다른 글

docker network mode  (0) 2022.12.06
Postgresql Last Insert Id 얻기  (0) 2022.12.01
golang docker 말기  (0) 2022.11.24
golang 공유 자원 사용하기  (0) 2022.11.03
golang 간단한 pg 라이브러리  (0) 2022.11.02
반응형
version: '3.3'
services:
  redis:
    image: 'redis:6.0.5'
    environment:
      ALLOW_EMPTY_PASSWORD: "yes"
    ports:
    - 6379:6379
    volumes:
    - /mnt/d/docker/Redis/Log:/data
    - /mnt/d/docker/Redis/redis.conf:/usr/local/etc/redis/redis.conf
  mysql5.7:
    image: mysql:5.7.28
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: coral
    ports:
    - 3306:3306
    volumes:
    - /home/mysql5.7/Data:/var/lib/mysql
    - /home/mysql5.7/:/etc/mysql/
  postgreSQL:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: "test"      
    ports:
    - 5432:5432
    volumes:
    - /home/postgreSQL:/var/lib/postgresql/data

docker ps 로 이미명 찾자

 

# docker exec -it 4f85072fd34a bash

디비에 들어가자

 psql -U postgres

계정 생성

postgres=#  CREATE USER test PASSWORD 'test' SUPERUSER;

사용하자

 

+ Recent posts