{"id":21585200,"url":"https://github.com/patricktrainer/motherduck-connection","last_synced_at":"2026-05-05T11:33:19.083Z","repository":{"id":185134251,"uuid":"673027618","full_name":"patricktrainer/motherduck-connection","owner":"patricktrainer","description":"A Streamlit connection to MotherDuck 🦆","archived":false,"fork":false,"pushed_at":"2023-08-17T04:55:19.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T15:29:51.508Z","etag":null,"topics":["duckdb","motherduck","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","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/patricktrainer.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-07-31T17:46:32.000Z","updated_at":"2023-08-28T11:53:45.000Z","dependencies_parsed_at":"2025-01-24T15:39:07.683Z","dependency_job_id":null,"html_url":"https://github.com/patricktrainer/motherduck-connection","commit_stats":null,"previous_names":["patricktrainer/motherduck-connection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fmotherduck-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fmotherduck-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fmotherduck-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricktrainer%2Fmotherduck-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patricktrainer","download_url":"https://codeload.github.com/patricktrainer/motherduck-connection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189829,"owners_count":20412991,"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":["duckdb","motherduck","streamlit"],"created_at":"2024-11-24T15:09:27.864Z","updated_at":"2026-05-05T11:33:14.063Z","avatar_url":"https://github.com/patricktrainer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamlit MotherDuck Connection 🦆\n\nConnect to [MotherDuck](https://motherduck.com) from your Streamlit app seamlessly. This library, powered by `st.experimental_connection()`, offers a straightforward interface to establish and manage your connection to a MotherDuck database.\n\n## 🌟 Features\n- Simple connection establishment to MotherDuck using DuckDB.\n- Execute SQL queries and fetch results as DataFrames.\n- Cache support for repetitive queries to boost performance.\n\n## 🔧 Installation\n\n```bash\npip install motherduck-connection\n```\n\n## 🚀 Usage\n\n### Establishing a Connection\nInitiate an instance of the `MotherDuckConnection` class from the `motherduck_connection` module. Optionally provide a database path. If omitted, it'll connect to the default database (`my_db`).\n\n### Executing Queries\nUse the `query` method of the `MotherDuckConnection` instance to run SQL queries and fetch results.\n\n## 📖 Example Application: `app.py`\n\nThis example showcases how you can employ the `MotherDuckConnection` library in a Streamlit app to query MotherDuck.\n\n### 🌐 Features:\n1. **DuckDB Table Query**: Showcases a table from MotherDuck's sample data, displaying the top 20 stories from Hacker News. \n2. **Replies to a HN Post**: Lets users input a Hacker News post ID and fetches related replies.\n3. **Current HN Front Page**: Displays the present front page of Hacker News.\n\n### 🏃 Running the Example:\nNavigate to the `examples` directory and run:\n\n```bash\nstreamlit run app.py\n```\n\n## 📚 Helper Functions: `motherduck_sql.py`\n\nOffers functions to aid in querying data from MotherDuck and the Hacker News API.\n\n### 📋 Functions:\n1. **get_hn_item(id)**: Fetches the URL to retrieve an item from Hacker News.\n2. **get_hn_front_page()**: Gets the URL for Hacker News front page items.\n3. **query_hn_front_page(conn)**: Queries Hacker News front page with a MotherDuck connection, returning a DataFrame.\n4. **query_hn_items(conn, hn_item_id_input)**: Fetches an item and its comments from Hacker News based on a given ID.\n5. **query_motherduck(conn, table_name)**: Queries a table from MotherDuck, fetching 'story' type items.\n\n## 📜 License\nSee the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricktrainer%2Fmotherduck-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatricktrainer%2Fmotherduck-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricktrainer%2Fmotherduck-connection/lists"}