3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Django] select文でDBの中身を確認する

Posted at

前提

  • DB: postgresql
  • Shellアプリ: Terminal(Mac)

dbshellを使用します

起動

※設定ファイルを環境ごとに使い分けていない場合、--settingsオプションは不要です。

$ python manage.py dbshell --settings <project name>.<settingsファイル名(拡張子なし)>

テーブル一覧表示


dbname=> \dt
                         List of relations
 Schema |                 Name                 | Type  |   Owner
--------+--------------------------------------+-------+------------
 public | account_emailaddress                 | table | diary_user
 public | account_emailconfirmation            | table | diary_user
 public | accounts_customuser                  | table | diary_user
 public | accounts_customuser_groups           | table | diary_user
 public | accounts_customuser_user_permissions | table | diary_user
 public | auth_group                           | table | diary_user
 public | auth_group_permissions               | table | diary_user
 public | auth_permission                      | table | diary_user
 public | django_admin_log                     | table | diary_user
 public | django_content_type                  | table | diary_user
 public | django_migrations                    | table | diary_user
 public | django_session                       | table | diary_user
 public | django_site                          | table | diary_user
(13 rows)

指定したテーブルの全レコード表示

※django_siteはテーブル名


dbname=> select * from django_site;
 id |   domain    |    name
----+-------------+-------------
  1 | example.com | example.com
(1 row)

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?