DEV Community

Cover image for How to use Prisma Postgres πŸš€
Thomas Bnt
Thomas Bnt Subscriber

Posted on

How to use Prisma Postgres πŸš€

Introduction

On October 29, Prisma announced Prisma Postgres. Don't hesitate to read the blog, useful information! πŸ™Œ

It is built from the ground up and deployed via unikernels (think: hyper-specialized OS) that are running as ultra-lightweight microVMs on our own bare metal servers.

Thanks to that architecture, we’re able to offer unique benefits that you don’t get anywhere else:

  • A β€œserverless” database with pay-as-you-go pricing but no cold starts.
  • A generous free tier that you can use to explore the service and build small projects.
  • Thanks to the first-class integration with other Prisma products, you also get the following features out-of-the-box:
    • Real-time database event streams
    • Connection pooling
    • Caching
    • Query analysis and recommendations

Quick video presentation


How to use Prisma Postgres

Getting started: Get a new database

If you want, you have the Quickstart documentation about installing Prisma.

  1. Login into your Prisma Console account (it's free)
  2. Create a new project by clicking on the New project button
  3. Give it a beautiful name
  4. In the Prisma Postgres section, click to Get started Prisma Postgres section
  5. Select a region, and click to Create project
  6. You now have your database ! πŸ₯³

Setup your project

  1. Open your terminal
  2. Execute this command if you want a template

    npx try-prisma@latest --template databases/prisma-postgres --name hello-prisma --install npm
    
  3. Install dependencies

    thomasbnt@thomasbnt:~/lab$ npx try-prisma@latest --template databases/prisma-postgres --name beautiful-project --install npm
    Need to install the following packages:
    try-prisma@1.0.58
    Ok to proceed? (y) y
    βœ” Loaded 59 templates
    βœ” Downloaded and extracted the databases/prisma-postgres project in ./beautiful-project.
    βœ” Installed packages in ./beautiful-project.
    The project is good to go! Next steps:
    1. Navigate into ./beautiful-project to begin.
    2. Refer to the project README for detailed instructions on running the project:
    https://github.com/prisma/prisma-examples/tree/latest/databases/prisma-postgres
    If you have any feedback about this specific template, we want to hear it!
    Submit any feedback here: https://pris.ly/prisma-examples-feedback
    thomasbnt@thomasbnt:~/lab$ cd beautiful-project/
    
  4. Click on Generate database credentials and copying and pasting into your .env file in your project folder, but keep it private!
    Files in the project folder

  5. You can setup your database with a migration

    npx prisma migrate dev --name init
    

    Output:
    Output when executing a Prisma migrate command

  6. Optional: If you want sample data: npm run queries

  7. You can now see your database with the npx prisma studio πŸš€

Prisma studio with sample data

Useful links

Note: Some links are affiliate links. I may receive a commission when you take a paid offer.

Top comments (6)

Collapse
 
miracle_bonyu_3a1f41e3208 profile image
Miracle Bonyu

Thanks for sharing this.

Collapse
 
thomasbnt profile image
Thomas Bnt

Thanks you for reading the post ! πŸ™Œ

Collapse
 
callloop profile image
Call Loop

Good post!

Collapse
 
thomasbnt profile image
Thomas Bnt

Thanks you for reading the post and your comment ! πŸ™ŒπŸ˜„

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more