Giter VIP home page Giter VIP logo

pbd's Introduction

Pre

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04 Follow this tutorial. Even though it's written for Ubuntu 14.04 LTS, I suppose it's ok for every platform (with small differences like package manager). Let us suppose that you can type

sudo -i -u postres

And without any error enter PSQL by typing

psql

Create database

Well, In first order you need to create database. In fact, you could name it as you wish, but I suppose it would be reasonable to name it PBD as I did. Type:

create database PBD;

Do not forget about semicolon. It could be tricky.

\l

to list databases on your host. If there's one labeled pbd it's fine :)

Migrate

Let us suppose that you have .sql file with create table commands. type

\q

to leave psql and then go to folder with PBD_create.sql file. It's a default name from vertabello

psql pbd < PBD_create.sql

then in order do connect

psql
\c pbd
\d

I believe that everything went fine amd now you see 14 tables owned by mysterious postgres :) https://www.postgresql.org/docs/9.0/static/sql-select.html Here's postegres syntax. That's easy Check if everything is fine by:

select * from clients;

(semicolon!)

Populate

TBD. We's rather have to populate in proper order. It would be great if will make FK only to already existing fields :). Made example:

psql pbd < populate.sql

We can make long populaton script. But I think that we could also make it using DataGrip. Just populate it and then make a bump of database. And then we could run it on every machine.

Oooor, we can use elixir and be fancy and functonal

Elixir

Given you followed tutorial http://elixir-lang.github.io/install.html, let us make it runnable.
In order to get deps

mix deps.get

And run interactive mode

iex -S mix

The you could type

{:ok, pid} = Postgrex.start_link(hostname: "localhost", username: "postgres", password: "postgres", database: "pbd")
Postgrex.query!(pid, "SELECT * FROM conferences", [])

Looks fine. meh? :)
You could do it from file as well

iex -S mix
PBD.hello

:world! Look in lib/pbd.ex/ It's so easy

PBD.example

Ok, but do we really wish to compile all this shit every time? Maybe some script? ctr+c twice

mix run lib/population

This file will great some day :') and that's essential

pbd's People

Contributors

osdnk avatar malenczuk avatar

Stargazers

Wojciech Geisler avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.