Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beautydate/bigqueryid
https://github.com/beautydate/bigqueryid
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/beautydate/bigqueryid
- Owner: beautydate
- License: mit
- Created: 2016-10-13T21:40:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-03T12:18:40.000Z (about 8 years ago)
- Last Synced: 2024-03-15T14:09:22.240Z (11 months ago)
- Language: Ruby
- Size: 19.5 KB
- Stars: 2
- Watchers: 15
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# BigQueryID
BigQueryID is an ORM (Object-Relational-Mapper) framework for Google BigQuery in Ruby.
Install
-------
```sh
gem build bigqueryid.gem
gem install bigqueryid-.gem
```
or
```ruby
gem 'bigqueryid'
```Configure
---------
```sh
export GCLOUD_PROJECT=my-todo-project-id
export GCLOUD_KEYFILE_JSON=/path/to/keyfile.json
```Use
-------
```ruby
# Define product model product.rb
class Productinclude Bigquery::Base
dataset 'core'
table 'products'field :name, type: String
field :price, type: Float
field :barcodedef self.create_table
bigquery.dataset(self.dataset_name).create_table self.table_name do |schema|
schema.string 'barcode'
schema.timestamp 'created_at'
schema.integer 'id'
schema.string 'name'
schema.float 'price'
schema.timestamp 'updated_at'
end unless table_exist?
enddef self.fetch_all
sql = <<-SQL.squish
SELECT
*
FROM core.products
ORDER BY
P.name
SQL
fetch sql
end
end# Return if table exists
Product.table_exist?# Delete table
Product.delete_table# Delete and create table
Product.flush# Fetch all rows
Product.fetch_all```