GithubHelp home page GithubHelp logo

navneetgupta / db_elixir Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 2.25 MB

Db Seeding and Migration from one DB to Another DB, Http Api supporting chunk_encoding

Elixir 100.00%
elixir postgresql plug chunk-encoding

db_elixir's Introduction

DbTest

Running the application

configuration

vi apps/dbs/config/config.exs
vi apps/dbs/config/dev.exs

Checking Out the code.

git clone https://github.com/Navneet-gupta01/db_elixir.git
cd db_elixir

Testing The application

mix test

Creating DB and Schema

mix init

Seeding Databse Foo

One Way

iex -S mix
iex> Dbs.Program.import

Another Way

time mix run -e "Dbs.Program.import"

Faster Way of Seeding Databse Foo( Using bulk insert)

One Way

iex -S mix
iex> Dbs.Program.import2

Another Way

time mix run -e "Dbs.Program.import2"

Another Faster Way of Seeding Databse Foo( Using COPY method)

One Way

iex -S mix
iex> Dbs.Program.import_copy

Another Way

time mix run -e "Dbs.Program.import_copy"

Migrating Data from FOO(source) to BAR(dest)

One Way

iex -S mix
iex> Dbs.Program.copy_from_foo_to_bar

Another Way

time mix run -e "Dbs.Program.copy_from_foo_to_bar"

Accessing Rest Apis

iex -S mix

Or

mix run --no-halt

Rest Apis Specs

curl -vvv http://localhost:9000/dbs/bar/tables/dest\?from_id\=999990

curl -vvv http://localhost:9000/dbs/foo/tables/source\?from_id\=999990
  • from_id is Optional Query param default to 0, it will start streaming from start.
Response:

$ curl -vvv http://localhost:9000/dbs/foo/tables/source\?from_id\=999990
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 9000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9000 (#0)
> GET /dbs/foo/tables/source?from_id=999990 HTTP/1.1
> Host: localhost:9000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< cache-control: max-age=0, private, must-revalidate
< content-type: text/event-stream; charset=utf-8
< date: Sun, 26 May 2019 04:44:14 GMT
< server: Cowboy
< transfer-encoding: chunked
<
a,b,c
999991, 1, 1
999992, 2, 2
999993, 0, 3
999994, 1, 4
999995, 2, 0
999996, 0, 1
999997, 1, 2
999998, 2, 3
999999, 0, 4
1000000, 1, 0

Further Improvement that can be worked on.

  • While Streaming data through Http Api's, DB's is checked frequently for any update. It could be avoided using A Pub-Sub channel. Http_Api can subscribe to different sources (here dest/source tables changes.). And once record are inserted a event could be published to the corresponding subscriber.

db_elixir's People

Contributors

navneetgupta 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.