Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

PostgreSQL: Difference between revisions

From Nest Guides
Samuel (talk | contribs)
Add PostgreSQL page
 
Lukeo (talk | contribs)
Say as less in that one sentence
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[https://www.postgresql.org/ PostgreSQL] is a popular and widely-used SQL relational database. It's used for projects as small as my tiny side projects as well as projects as large as [https://hcb.hackclub.com HCB]. Since it's used so often, Nest runs an instance of Postgres that you can use without having to spin up a whole new instance that could use a lot of resources.
[https://www.postgresql.org/ PostgreSQL] is a popular and widely-used SQL relational database used for projects of any size. Since it's used so often, Nest runs an instance of Postgres that you can use without having to spin up a whole new instance that could use a lot of resources.


== How to use Nest Postgres ==
== How to use Nest Postgres ==
Line 5: Line 5:
  psql
  psql
and you'll enter the interactive Postgres shell where you can run SQL like normal. Since Nest Postgres is publicly accessible, you can also connect to it from any other machine, including wherever your apps may run, such as Vercel!
and you'll enter the interactive Postgres shell where you can run SQL like normal. Since Nest Postgres is publicly accessible, you can also connect to it from any other machine, including wherever your apps may run, such as Vercel!
When you're just using the <code>psql</code> client on Nest, you don't need to specify your username and password, but if you're connecting to Postgres over a network, then you will need to authenticate. Your username and password will be the same username and password that you use for Nest!
=== Databases ===
By default, a Postgres database is created for you, with your Nest username as the database name. You can connect to your database by running the following in the Postgres client:
\c <username>;
If you'd like to create new databases, no worries! You can create a new database with the [[Nest CLI]], by running
nest db create <name>
The Nest CLI will create a new database for you with your Nest username prefixed to it - for example, if your Nest username was <code>orpheus</code> and you ran <code>nest db create slackbot</code>, the new database would be named <code>orpheus_slackbot</code>.

Latest revision as of 17:57, 31 May 2024

PostgreSQL is a popular and widely-used SQL relational database used for projects of any size. Since it's used so often, Nest runs an instance of Postgres that you can use without having to spin up a whole new instance that could use a lot of resources.

How to use Nest Postgres

Nest Postgres is just a simple instance of PostgreSQL 16 that you can access with your Nest username and password. To launch the Postgres client, you can simply run:

psql

and you'll enter the interactive Postgres shell where you can run SQL like normal. Since Nest Postgres is publicly accessible, you can also connect to it from any other machine, including wherever your apps may run, such as Vercel!

When you're just using the psql client on Nest, you don't need to specify your username and password, but if you're connecting to Postgres over a network, then you will need to authenticate. Your username and password will be the same username and password that you use for Nest!

Databases

By default, a Postgres database is created for you, with your Nest username as the database name. You can connect to your database by running the following in the Postgres client:

\c <username>;

If you'd like to create new databases, no worries! You can create a new database with the Nest CLI, by running

nest db create <name>

The Nest CLI will create a new database for you with your Nest username prefixed to it - for example, if your Nest username was orpheus and you ran nest db create slackbot, the new database would be named orpheus_slackbot.