Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Node.js Client for Postgres v14

NotificationsYou must be signed in to change notification settings

mpolinowski/postgres-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker

Run the Postgres Container

docker run -d --rm \    --name postgres \    -e POSTGRES_PASSWORD=secretpassword \    -p 5432:5432 \    postgres:14

Connect to the Postgres CLI:

dockerexec -ti -u postgres postgres psqlpsql (14.0 (Debian 14.0-1.pgdg110+1))Type"help"for help.postgres=#

Setting up the Database

Create a Database

CREATEDATABASEbooks;

Switch to using the new books table instead of the default postgres:

\connect books;You are now connected to database"books"as user"postgres".

Add a Table

CREATETABLEthe_expanse (  book_idINTEGERPRIMARY KEY GENERATED ALWAYSAS IDENTITY,  titleVARCHAR (25 ) UNIQUENOT NULL,  isbnVARCHAR (25 ) UNIQUENOT NULL,  yearINT,  pagesINT,  created_onTIMESTAMPNOT NULL);

Add Data

INSERT INTO the_expanse   (title, isbn, year, pages, created_on)VALUES   ('Leviathan Wakes','978-0-316-12908-4',2011,592, NOW()- interval'1256 days'),  ('Calibans War','978-1-841-49990-1',2012,595, NOW()- interval'993 days'),  ('Abaddons Gate','978-0-316-12907-7',2013,539, NOW()- interval'765 days'),  ('Cibola Burn','978-0-316-21762-0',2014,583, NOW()- interval'543 days'),  ('Nemesis Games','978-0-316-21758-3',2015,544, NOW()- interval'267 days'),  ('Babylons Ashes','978-0-316-33474-7',2016,608, NOW()- interval'189 days'),  ('Persepolis Rising','978-0-316-33283-5',2017,560, NOW()- interval'122 days'),  ('Tiamats Wrath','978-0-316-33286-6',2019,544, NOW()- interval'98 days'),  ('Leviathan Falls','978-0-356-51039-2',2021,528, NOW()- interval'21 days');

Node.js Client

Start the Client

 npm install node server_express.jsrunning on http://localhost:8888

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp