12/29/2022 0 Comments Postgres create databaseWe need to create the extension “uuid-ossp” so that we can use the function uuid_generate_v4() to auto-generate our clothes_stock id’s. Then we need to connect to the database to create the TYPE’s colours, sexes and sizes. You should then be able to run psql in the Terminal Create SQL scriptįor this project we are creating a clothes store, so we need to keep track of the stock of the store, below is the script (ClothesShop.sql) we will run: CREATE DATABASE clothes_shop \c clothes_shop CREATE TYPE colours AS ENUM ('blue', 'green', 'red', 'yellow') CREATE TYPE sexes AS ENUM ('male', 'female') CREATE TYPE sizes AS ENUM ('small', 'medium', 'large') CREATE EXTENSION IF NOT EXISTS "uuid-ossp" CREATE TABLE clothes_stock ( id UUID NOT NULL DEFAULT uuid_generate_v4(), clothes_name TEXT NOT NULL, price NUMERIC NOT NULL, cost NUMERIC NOT NULL, colour colours NOT NULL, sex sexes NOT NULL, clothes_size sizes NOT NULL, stock_level int NOT NULL ) INSERT INTO clothes_stock (clothes_name, price, cost, colour, sex, clothes_size, stock_level) VALUES ('Red T-shirt', 1.99, 0.99, 'red', 'male', 'small', 100) įirstly we create the database called “clothes_shop”. If you are using Mac the simplest way of doing this is using Homebrew (see ) once you have Homebrew installed in your Terminal you can run the following to install Postgres: brew install postgresql brew services start postgres Create a types for Clothes Types, Colours, Sexes and Sizes.We’ll be doing the following to setup the database: This post is to support Episode 2 where we will create a Postgres database for our Python Application to interact with. #Postgres create database how to#I have recently put together a weekly tutorial series for how to build a scalable Python application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |