{"id":19806533,"url":"https://github.com/monade/any_query","last_synced_at":"2026-06-16T09:31:53.841Z","repository":{"id":169348098,"uuid":"645276556","full_name":"monade/any_query","owner":"monade","description":"An ORM for any data source (SQL, CSV, TSV, REST API)","archived":false,"fork":false,"pushed_at":"2023-09-29T09:46:26.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T13:04:13.251Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-25T09:50:03.000Z","updated_at":"2023-05-25T09:52:44.000Z","dependencies_parsed_at":"2023-09-29T12:02:42.698Z","dependency_job_id":null,"html_url":"https://github.com/monade/any_query","commit_stats":null,"previous_names":["monade/any_query"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/monade/any_query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Fany_query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Fany_query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Fany_query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Fany_query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monade","download_url":"https://codeload.github.com/monade/any_query/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Fany_query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34400451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-12T09:07:49.850Z","updated_at":"2026-06-16T09:31:53.825Z","avatar_url":"https://github.com/monade.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Tests](https://github.com/monade/any_query/actions/workflows/test.yml/badge.svg)\n[![Gem Version](https://badge.fury.io/rb/any_query.svg)](https://badge.fury.io/rb/any_query)\n\n# any_query\n\n`any_query` is a versatile ORM designed to interface with various data sources including SQL, CSV, TSV, Fixed Length Text Format, and REST APIs. With any_query, you can write SQL-like queries and receive results as ActiveRecord-like objects. It supports operations like `select`, `limit`, and even `joins` across different data sources.\n\n## Features\n* Unified Query Language: Write SQL-like queries for any supported data source.\n* ActiveRecord-like Objects: Get results in a familiar format.\n* Cross-data Source Joins: Combine data from different sources seamlessly.\n\n## Installation\n\nTo install `any_query`, add the gem to your Gemfile:\n\n```ruby\n  gem 'any_query'\n```\n\nThen run:\n\n```bash\n  bundle install\n```\n\n## Usage\n### Setting up Models\nTo use `any_query`, include it in your model and set up the necessary adapters:\n\n\n```ruby\nclass Invoice\n  include AnyQuery\n\n  adapter :http do\n    url 'https://your-api.dev'\n    primary_key :id\n    endpoint :list, :get, '/v2/invoices',\n             pagination: { type: :page, params: { per: 'pageSize', number: 'skippages' } },\n             wrapper: :collection,\n             default_params: {\n               query: { pageSize: 1000 },\n               headers: {\n                 'Content-Type': 'application/json'\n               }\n             }\n    endpoint :show, :get, '/v2/invoices{id}',\n             default_params: {\n               headers: {\n                 'Content-Type': 'application/json'\n               }\n             }\n  end\nend\n\nclass Customer\n  include AnyQuery\n\n  adapter :http do\n    url 'https://your-api.dev'\n    primary_key :id\n    endpoint :list, :get, '/customers/',\n             pagination: { type: :page, params: { per: 'pageSize', cursor: 'cursor', number: 'skippages' } },\n             wrapper: :collection,\n             default_params: {\n               query: { pageSize: 1000 },\n               headers: {\n                 'Content-Type': 'application/json'\n               }\n             }\n    endpoint :show, :get, '/customers/{id}',\n             default_params: {\n               headers: {\n                 'Content-Type': 'application/json'\n               }\n             }\n  end\nend\n```\n\n### Writing Queries\nWith your models set up, you can now write queries:\n\n```ruby\n  Invoice\n    .joins(Customer, :customerNumber, %i[customer customerNumber], into: :customer, strategy: :full_scan)\n    .select(\n      :number, :date, %i[customer name], %i[customer customerNumber], :netAmount\n    # :dueDate\n    ).to_a\n```\n\n### Standalone Mode\nYou can also use `any_query` without models by creating a client directly:\n\n```ruby\n  sql_client = AnyQuery::Client.new(\n    adapter: :sql,\n    params: {\n      url: 'psql://user:password@localhost:5432/dbname',\n      primary_key: :id,\n      table: 'users'\n    }\n  )\n\n  csv_client = AnyQuery::Client.new(\n    adapter: :csv,\n    params: {\n      url: 'path/to/file.csv',\n      primary_key: :id,\n      fields: {\n        id: { type: :integer },\n        user_id: { type: :integer },\n        title: { type: :string },\n        body: { type: :string },\n        status: { type: :integer },\n        created_at: { type: :datetime, format: '%Y-%m-%d %H:%M:%S' }\n      }\n    }\n  )\n\n  # Querying\n  csv_client\n    .joins(sql_client, :user_id, :id, into: :user, strategy: :full_scan)\n    .select(:number, :date, :customerNumber, :netAmount)\n    .to_a\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nAbout Monade\n----------------\n\n![monade](https://monade.io/wp-content/uploads/2021/06/monadelogo.png)\n\nany_query is maintained by [mònade srl](https://monade.io/en/home-en/).\n\nWe \u003c3 open source software. [Contact us](https://monade.io/en/contact-us/) for your next project!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Fany_query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonade%2Fany_query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Fany_query/lists"}