{"id":17981137,"url":"https://github.com/gr8distance/blanton","last_synced_at":"2025-03-25T18:31:09.630Z","repository":{"id":52440125,"uuid":"283776288","full_name":"gr8distance/blanton","owner":"gr8distance","description":"BigQuery API wrapped by Elixir","archived":false,"fork":false,"pushed_at":"2022-06-30T08:02:46.000Z","size":75,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T18:10:56.333Z","etag":null,"topics":["bigquery","bigquery-schema","elixir"],"latest_commit_sha":null,"homepage":"https://github.com/gr8distance/blanton","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gr8distance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-30T13:01:54.000Z","updated_at":"2024-02-16T03:10:45.000Z","dependencies_parsed_at":"2022-09-12T11:32:53.090Z","dependency_job_id":null,"html_url":"https://github.com/gr8distance/blanton","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr8distance%2Fblanton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr8distance%2Fblanton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr8distance%2Fblanton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr8distance%2Fblanton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr8distance","download_url":"https://codeload.github.com/gr8distance/blanton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245519938,"owners_count":20628800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","bigquery-schema","elixir"],"created_at":"2024-10-29T18:07:52.654Z","updated_at":"2025-03-25T18:31:09.240Z","avatar_url":"https://github.com/gr8distance.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blanton\n\n* Blanton is a BigQuery library written by Elixir.\n\n## Installation\n\n1. Add Blanton to your list of dependencies in mix.exs:\n\n```elixir\ndef deps do\n  [\n    {:blanton, \"~\u003e 0.2.2\"}\n  ]\nend\n```\n\n2. Pass in your credentials json downloaded from your GCE account:\n\n```elixir\nconfig :goth,\n  json: \"path/to/google/json/creds.json\" |\u003e File.read!\n```\n\n3. If you have one dataset to operate on, you can also set it first.\n\n```elixir\nconfig :blanton,\n  project_id: \"\",\n  dataset_id: \"\"\n```\n\n## You can do\n\n- Dataset\n  - [x] Create\n  - [x] Delete\n- Table\n  - [x] Select\n  - [x] Create\n  - [x] Create(Option usable)\n  - [x] Update\n  - [x] Delete\n- Record\n  - [x] Insert\n  - [x] Select\n\n## Usage\n\n* Find records\n\n```elixir\nQuery.table(\"users\")\n|\u003e Query.pluck([\"name\", \"age\"])\n|\u003e Query.where([age: 31])\n|\u003e Query.limit(10)\n|\u003e Query.run\n|\u003e Query.to_records\n```\n\n* You can use below\n\n| input                                      | output                                 |\n|--------------------------------------------|----------------------------------------|\n| age: 16                                    | \"age = 16\"                             |\n| name: \"桜坂しずく\", age: 16                | \"name = '桜坂しずく' AND age = 16\"     |\n| {:in, :name, [\"桜坂しずく\", \"中須かすみ\"]} | \"name IN ('桜坂しずく', '中須かすみ')\" |\n| {:between, :age, 15, 17}                   | \"age BETWEEN 15 AND 17\"                |\n| {:like, :name, \"かな%\"}                    | \"name LIKE 'かな%'\"                    |\n| {:\u003c=, :age, 18}                            | \"age \u003c= 18\"                            |\n| \"name = ?\", \"中須かすみ\"                   | \"name = '中須かすみ'\"                  |\n| \"name = ? OR age \u003e 15\", [\"桜坂しずく\", 16] | \"name = '桜坂しずく' OR age \u003e 15\"      |\n\n* Create table\n\n```elixir\ncolumns = [\n  %{name: \"name\", mode: :string, type: :required},\n  %{name: \"age\", mode: :int64, type: :nullable}\n]\ntable = Blanton.Table.new(\"users\", columns)\nBlanton.Table.create(\"PROJECT_ID\", \"DATASET_ID\", table)\n\n# if you set dataset_id and project_id to config.exs\nBlanton.Table.create(table)\n```\n\n* Insert record\n\n```elixir\nrecords = [\n  %{name: \"安室透\", age: 29},\n  %{name: \"赤井秀一\", age: 32},\n]\ntable_name = \"users\"\nBlanton.Record.insert(\"PROJECT_ID\", \"DATASET_ID\", table_name, records)\n\n# if you set dataset_id and project_id to config.exs\nBlanton.Record.insert(table_name, records)\n```\n\n* Create migration file\n\n```elixir\n# lib/APP_NAME/bq_schema/TABLE_NAME.ex\n\ndefmodule APP_NAME.BqSchema.TABLE_NAME do\n  use Blanton.Schema\n\n  schema :TABLE_NAME do\n    field :column_name, :string, :required\n    field :some_field_column, :record, :repeated, [\n      sub_field(:name, :string, :nullable),\n      sub_field(:price, :int64, :nullable),\n    ]\n  end\n\n  # options do\n  #   partitiondate\n  #   register :timePartitioning, %GoogleApi.BigQuery.V2.Model.TimePartitioning{type: \"DAY\"}\n  # end\nend\n```\n\n\n* After creating the file, run the following command.\n  * `mix bq.migrate lib/bq_schema`\n* If you want to delete the table use the following command\n  * `mix bq.drop`\n  * **Please be careful because it cannot be stopped even if you execute it by mistake.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr8distance%2Fblanton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr8distance%2Fblanton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr8distance%2Fblanton/lists"}