{"id":28938155,"url":"https://github.com/tarellel/activerecord-duckdb","last_synced_at":"2026-04-03T10:32:05.780Z","repository":{"id":300152624,"uuid":"1005355920","full_name":"tarellel/activerecord-duckdb","owner":"tarellel","description":"A DuckDB database adapter for ActiveRecord","archived":false,"fork":false,"pushed_at":"2025-06-20T05:54:20.000Z","size":66,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-25T02:02:09.665Z","etag":null,"topics":["activerecord","duckdb","rails","ruby","rubygem","rubyonrails"],"latest_commit_sha":null,"homepage":"","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/tarellel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T05:25:20.000Z","updated_at":"2025-06-24T09:23:27.000Z","dependencies_parsed_at":"2025-06-24T01:01:40.834Z","dependency_job_id":null,"html_url":"https://github.com/tarellel/activerecord-duckdb","commit_stats":null,"previous_names":["tarellel/activerecord-duckdb"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tarellel/activerecord-duckdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarellel%2Factiverecord-duckdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarellel%2Factiverecord-duckdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarellel%2Factiverecord-duckdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarellel%2Factiverecord-duckdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarellel","download_url":"https://codeload.github.com/tarellel/activerecord-duckdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarellel%2Factiverecord-duckdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261836401,"owners_count":23217233,"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":["activerecord","duckdb","rails","ruby","rubygem","rubyonrails"],"created_at":"2025-06-22T22:06:59.984Z","updated_at":"2026-04-03T10:32:05.772Z","avatar_url":"https://github.com/tarellel.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Activerecord::Duckdb\n\nThis gem is a DuckDB database adapter for ActiveRecord.\n\n## Description\n\nActiverecord::Duckdb providers DuckDB database access for Ruby on Rails applications.\n\n~ **NOTE:** This gem is still a work in progress, so it might not work exactly as expected just yet. Some ActiveRecord features haven’t been added and/or fully tested.\n\n## Requirements\n\nThis gem relies on the [ruby-duckdb](https://github.com/suketa/ruby-duckdb) ruby gem as its database adapter. Thus it provides a seamless integration with the DuckDB database.\n\nBoth gems requires that you have [duckdb](https://duckdb.org). DuckDB has many installation options available that can be found on their [installation page](https://duckdb.org/docs/installation/).\n\n```ruby\n# OSx\nbrew install duckdb\n\n# Most Linux distributions\ncurl https://install.duckdb.org | sh\n```\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```bash\nbundle add \"activerecord-duckdb\"\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```bash\ngem install activerecord-duckdb\n```\n\n## Usage\n\n### Configuration\n\nAdjust your `database.yml` file to use the duckdb adapter.\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: db/development.duckdb\n\ntest:\n  adapter: duckdb\n  database: db/test.duckdb\n\nproduction:\n  adapter: duckdb\n  database: db/production.duckdb\n```\n\nRun some migrations to ensure the database is ready.\n\n```bash\nrails g model Notice name:string email:string content:string\n```\n\n```ruby\nNotice.create(name: 'John Doe', email: 'john@example.com', content: 'Something happened at work today!')\nNotice.find_by(email: 'john@example.com')\nNotice.all\nNotice.last.delete\n```\n\n~ At the moment using an in-memory database is very limited and still in development.\n**NOTE:** When using a memory database, any transactional operations will be lost when the process exits.\nThe only reason I can think of is that you might want to use an in-memory database for testing purposes, data analysis, or some sort of quick calculations where the data is not critical.\n\n```yaml\ntemporary_database:\n  adapter: duckdb\n  database: :memory\n```\n\n```ruby\nclass User \u003c ApplicationRecord\n  establish_connection(:temporary_database)\nend\n```\n\nOf you can set your own database configuration in the `config/database.yml` file.\nWhen using temporary databases you'll also have to generate your own schema on the fly rather than migrations creating them automatically.\n\n```yml\ntest:\n  adapter: duckdb\n  database: :memory\n\nproduction:\n  adapter: duckdb\n  database: :memory\n```\n\n### Advanced Connection Configuration\n\nThe adapter supports advanced configuration options for extensions, settings, secrets, and database attachments. These are configured in your `database.yml` file.\n\n#### Extensions\n\nInstall and load DuckDB extensions automatically on connection:\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: db/development.duckdb\n  extensions:\n    - httpfs\n    - postgres_scanner\n    - parquet\n```\n\n#### Settings\n\nConfigure DuckDB settings. The adapter applies secure defaults which you can override:\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: db/development.duckdb\n  settings:\n    threads: 4\n    memory_limit: '2GB'\n    max_temp_directory_size: '8GB'\n```\n\n**Default Settings:**\n\n| Setting | Default Value | Description |\n|---------|---------------|-------------|\n| `allow_persistent_secrets` | `false` | Disable persistent secrets for security |\n| `allow_community_extensions` | `false` | Disable community extensions |\n| `autoinstall_known_extensions` | `false` | Disable auto-installing extensions |\n| `autoload_known_extensions` | `false` | Disable auto-loading extensions |\n| `threads` | `1` | Number of threads for query execution |\n| `memory_limit` | `'1GB'` | Maximum memory usage |\n| `max_temp_directory_size` | `'4GB'` | Maximum temp directory size |\n\n**Notes:**\n- `allow_persistent_secrets` and `allow_community_extensions` are applied before loading extensions\n- `lock_configuration = true` is automatically applied at the end to lock all settings\n\n#### Secrets\n\nConfigure secrets for accessing external services (S3, PostgreSQL, etc.). Two styles are supported:\n\n**Style 1: Unnamed secrets** (key is the secret type):\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: ducklake\n  secrets:\n    postgres:\n      host: localhost\n      database: mydb\n      user: admin\n      password: secret\n    s3:\n      key_id: AKIAIOSFODNN7EXAMPLE\n      secret: wJalrXUtnFEMI/K7MDENG\n      region: us-east-1\n```\n\n**Style 2: Named secrets** (explicit `type` key, hash key becomes secret name):\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: ducklake\n  secrets:\n    my_prod_bucket:\n      type: s3\n      key_id: AKIAIOSFODNN7EXAMPLE\n      secret: wJalrXUtnFEMI/K7MDENG\n      region: us-east-1\n      scope: 's3://prod-bucket'\n    my_dev_bucket:\n      type: s3\n      key_id: AKIAIOSFODNN7EXAMPLE2\n      secret: anotherSecretKey\n      region: us-west-2\n      scope: 's3://dev-bucket'\n```\n\nNamed secrets allow multiple secrets of the same type with different scopes.\n\n#### Database Attachments\n\nAttach external databases (PostgreSQL, MySQL, DuckLake, etc.):\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: ducklake\n  extensions:\n    - postgres_scanner\n    - ducklake\n  secrets:\n    postgres:\n      host: localhost\n      database: mydb\n      user: admin\n      password: secret\n  attachments:\n    - name: pg_db\n      connection_string: 'postgres:'\n      type: POSTGRES\n    - name: ducklake\n      connection_string: 'ducklake:postgres:'\n      options: \"DATA_PATH 's3://my-bucket', ENCRYPTED\"\n```\n\nIf you need to switch to a specific attached database after configuration, you can use the `use_database` option:\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: db/development.duckdb\n  attachments:\n    - name: analytics\n      connection_string: 's3://bucket/analytics.duckdb'\n  use_database: analytics  # Switch to the attached database\n```\n\n### Sample App setup\n\nThe following steps are required to setup a sample application using the `activerecord-duckdb` gem:\n\n1. Create a new Rails application:\n\n```bash\nrails new sample_app --database=sqlite3\n```\n\n2. Add the `activerecord-duckdb` gem to your Gemfile:\n\n```ruby\ngem 'activerecord-duckdb'\n```\n\n3. Run `bundle install` to install the gem.\n\n4. Update the `config/database.yml` file to use the `duckdb` adapter:\n\n```yaml\ndevelopment:\n  adapter: duckdb\n  database: db/development.db\n\ntest:\n  adapter: duckdb\n  database: :memory\n\nproduction:\n  adapter: duckdb\n  database: :memory\n```\n\n5. Generate a model for the sample application:\n\n```bash\nrails g model User name:string email:string\n```\n\n5. Run some migrations to ensure the database is ready:\n\n```bash\nrails db:create; rails db:migrate\n```\n\n6. Create some sample data:\n\n```ruby\nUser.create(name: 'John Doe', email: 'john@example.com')\nUser.create(name: 'Jane Doe', email: 'jane@example.com')\n```\n\n7. Run some queries:\n\n```ruby\nUser.all\nUser.find_by(email: 'john@example.com')\nUser.last.delete\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tarellel/activerecord-duckdb.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarellel%2Factiverecord-duckdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarellel%2Factiverecord-duckdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarellel%2Factiverecord-duckdb/lists"}