https://github.com/captn3m0/jekyll-sqlite Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} captn3m0 / jekyll-sqlite Public * Notifications You must be signed in to change notification settings * Fork 4 * Star 179 A Jekyll plugin to use SQLite databases as a data source. 179 stars 4 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights captn3m0/jekyll-sqlite main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 28 Commits .github/workflows .github/workflows bin bin lib lib test test .gitignore .gitignore .rubocop.yml .rubocop.yml CHANGELOG.md CHANGELOG.md CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md Gemfile Gemfile README.md README.md Rakefile Rakefile jekyll-sqlite.gemspec jekyll-sqlite.gemspec View all files Repository files navigation * README * Code of conduct Jekyll SQLite plugin A Jekyll generator plugin to lets you use SQLite database instead of data files as a data source. It lets you easily create APIs and websites from a SQLite database, by linking together a database file, your template, and the relevant queries. It supports site-level queries, per-page queries, and prepared queries that can use existing data (possibly generated via more queries) as parameters. Continuous Integration Gem Version Installation Add this line to your site's Gemfile: gem 'jekyll-sqlite' And then add this line to your site's _config.yml: plugins: - jekyll_sqlite Usage A fully-functional demo website that uses this plugin is available at northwind.captnemo.in. The source code for the demo is available at captn3m0/northwind. Update your _config.yml to define your data sources with your SQLite database. ... sqlite: - data: customers file: *db query: SELECT * from Customers Then, you can use the site.data attributes accordingly: {{ site.data.customers | jsonify }} Prepared Queries This plugin supports prepared queries with parameter binding. This lets you use existing data from a previous query, or some other source (such as site.data.* or page.*) as a parameter in your query. Say you have a YAML file defining your items (data/books.yaml): - id: 31323952-2708-42dc-a995-6006a23cbf00 name: Time Travel with a Rubber Band - id: 5c8e67a0-d490-4743-b5b8-8e67bd1f95a2 name: The Art of Cache Invalidation and the prices for the items in your SQLite database, the following configuration will enrich the items array with the price: sql: - data: items.books query: SELECT price, author FROM pricing WHERE id =:id db: books.db This would allow the following Liquid loop to be written: {% for item in site.data.items %} {{item.meta.price}}, {{item.meta.author}} {% endfor %} Per Page Queries The exact same syntax can be used on a per-page basis to generate data within each page. This is helpful for keeping page-specific queries within the page itself. Here's an example: --- FeaturedSupplierID: 2 sqlite: - data: suppliers file: "_db/northwind.db" query: "SELECT CompanyName, SupplierID FROM suppliers ORDER BY SupplierID" - data: suppliers.products # This is a prepared query, where SupplierID is coming from the previous query. file: "_db/northwind.db" query: "SELECT ProductName, CategoryID,UnitPrice FROM products WHERE SupplierID = :SupplierID" # :FeaturedSupplierID is picked up automatically from the page frontmatter. - data: FeaturedSupplier file: "_db/northwind.db" query: "SELECT * SupplierID = :FeaturedSupplierID" --- {{page.suppliers|jsonify}} This will generate a page.suppliers array with all the suppliers, and a page.FeaturedSupplier object with the details of the featured supplier. Each supplier will have a products array with all the products for that supplier. Generating Pages It works well with the datapage_gen plugin: See the datapage_gen docs for more details. Here's a sample configuration: sqlite: restaurants: file: _db/reviews.db sql: SELECT id, name, last_review_date > 1672531200 as active, address FROM restaurants; page_gen: - data: restaurants template: restaurant name: id title: name filter: active This will automatically generate a file for each restaurant restaurants/#{id}.html file with the layout _layouts/restaurant.html and page.id, page.name, page.active set and page.title set to restaurant name Note that the datapage_gen plugin will run after the jekyll-sqlite plugin, if you generate any pages with per-page queries, these queries will not execute. Development After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org. Contributing Bug reports and pull requests are welcome on GitHub at https:// github.com/captn3m0/jekyll-sqlite. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct. Note that only maintained versions of Jekyll and Ruby are supported. Code of Conduct Everyone interacting in the Jekyll::Sqlite project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct. About A Jekyll plugin to use SQLite databases as a data source. Resources Readme Code of conduct Code of conduct Activity Stars 179 stars Watchers 2 watching Forks 4 forks Report repository Releases 3 tags Languages * Ruby 98.6% * Shell 1.4% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.