Help us understand the problem. What is going on with this article?

Heroku Postgres を使ってみる

More than 1 year has passed since last update.

手順

1. Heroku のアカウントを用意

2. Heroku PostgresCreate Database をクリックし、表示されたモーダル内の Dev Plan(Free) を選択

HerokuPostgres.png

*※ 10,000 行までは無料で使用することができる *

3. psql で接続

  1. psql -h hostname -U username -d databasename
  2. パスワード入力

4. テーブルを作成し、データを挿入

-- テーブルを作成
CREATE TABLE sample
(
  crttimestamp timestamp with time zone,
  crtuser character varying(20),
  udttimestamp timestamp with time zone,
  udtuser character varying(20),
  id character varying(10) NOT NULL,
  name character varying(100) NOT NULL,
  CONSTRAINT sample_id_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
-- データを挿入
INSERT INTO sample(crttimestamp, crtuser, udttimestamp, udtuser, id, name) VALUES (current_timestamp, 'test', current_timestamp, 'test', '0000000001', 'test001');
INSERT INTO sample(crttimestamp, crtuser, udttimestamp, udtuser, id, name) VALUES (current_timestamp, 'test', current_timestamp, 'test', '0000000002', 'test002');
INSERT INTO sample(crttimestamp, crtuser, udttimestamp, udtuser, id, name) VALUES (current_timestamp, 'test', current_timestamp, 'test', '0000000003', 'test003');
select * from sample;

困ったこと

ssl で接続しないと下記のエラーが発生した。
heroku postgres の pg_hba.conf は編集できないので、SSLモードで接続するようにする。

FATAL: no pg_hba.conf entry for host "[host ip address]", user "[user name]", database "[database name]", SSL off

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした