FastAPI SQLite3 Setting Up Todos - 36

2022. 12. 30. 23:48·Develop/FastAPI
728x90
SMALL
터미널로 sqllite3 데이터베이스를 조작하는 것이 목표
파이썬 사용 툴: Pycharm / 운영체제: Mac

 

1. pycharm 터미널에서 데이터베이스 접속하기 해당 값을 입력

sqlite3 todos.db

 

2. 데이터베이스 내의 테이블을 확인

sqlite> .schema

 

3. 테이블에 데이터를 삽입해 보기

sqlite> insert into todos (title, description, priority, complete) values ('Go to the store', 'Pick up eggs', 5, False);
sqlite> insert into todos (title, description, priority, complete) values ('Cut the lawn', 'Grass is getting long', 3, False);
sqlite> insert into todos (title, description, priority, complete) values ('Feed the dog', 'He is getting hungry', 5, False);

 

4. 테이블의 데이터를 조회해 보기

sqlite> select * from todos;

 

5. 조회 결과 모드를 변경해 보기

#조회결과가 예쁘지 않다. 변경해보자

sqlite> .mode column
sqlite> select * from todos;

sqlite> .mode markdown
sqlite> select * from todos;

sqlite> .mode box
sqlite> select * from todos;

sqlite> .mode table
sqlite> select * from todos;

 

6. 추가적인 데이터 삽입 후 삭제해 보기

sqlite> insert into todos (title, description, priority, complete) values ('Test element', 'He is getting hungry', 5, False);
sqlite> select * from todos;
sqlite> delete from todos where id = 4;
sqlite> select * from todos;

 

7. 한번 더 삭제해 보기

sqlite> insert into todos (title, description, priority, complete) values ('A new test element', 'He is getting hungry', 5, False);
sqlite> select * from todos;
sqlite> delete from todos where id = 4;
sqlite> select * from todos;

※ 위 과정에서 id = 4를 지우고 다시 추가를 해도 id는 4로 다시 삽입이 되는 것을 볼 수 있다.

 

 

728x90
SMALL
저작자표시 비영리 변경금지 (새창열림)

'Develop > FastAPI' 카테고리의 다른 글

FastAPI sqlalchemy filter 사용하기(select) - 38  (0) 2023.01.01
FastAPI SessionLocal을 통한 테이블 읽기 - 37  (0) 2022.12.31
FastAPI SQL Queries Introduction - 35  (0) 2022.12.30
FastAPI Installation of SQLite3 Terminal (Mac) - 34  (0) 2022.12.30
FastAPI Installation of SQLite3 Terminal (Windows) - 34  (0) 2022.12.30
'Develop/FastAPI' 카테고리의 다른 글
  • FastAPI sqlalchemy filter 사용하기(select) - 38
  • FastAPI SessionLocal을 통한 테이블 읽기 - 37
  • FastAPI SQL Queries Introduction - 35
  • FastAPI Installation of SQLite3 Terminal (Mac) - 34
동석해요
동석해요
공부하고 싶은게 많은, 사소한 IT 지식들 공유
    250x250
  • 동석해요
    개발로 자기계발
    동석해요
  • 전체
    오늘
    어제
    • 분류 전체보기 (226)
      • Develop (126)
        • 기초지식 (12)
        • FastAPI (102)
        • Django (11)
      • Database & Data (62)
        • 기초지식 (16)
        • MySQL (29)
        • PostgreSQL (8)
        • 데이터 분석 (9)
      • 인공지능 (11)
        • PyTorch (9)
      • Cloud (8)
        • AWS (4)
        • GCP (2)
      • 버그처리 (14)
      • 회고 & 일상 (5)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.3
동석해요
FastAPI SQLite3 Setting Up Todos - 36
상단으로

티스토리툴바