Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:58:41+00:00 2026-06-08T06:58:41+00:00

Is there any way to make SASS compile data passed from database? I can

  • 0

Is there any way to make SASS compile data passed from database? I can use DBI + ODBC to get data from MSSQL Server 2008, but how do I make SASS compile passed data instead of file?

Didn’t find anything useful, and changing sass core files doesn’t sound like a best idea… Especially considering zero Ruby knowledge.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:58:43+00:00Added an answer on June 8, 2026 at 6:58 am

    I ended up using this chunk of code. Totally not elegant, but I hope it will help someone with pervertish needs.

    sql.rb in sass gem dir:

    require 'dbi'
    require 'sass'
    require config with database credentials
    
    if File.exist?(config)
        require config
    
        SQL_OPTIONS = {
            :style => :nested,
            :load_paths => ['.'],
            :cache => true,
            :cache_location => './.sass-cache',
            :syntax => :scss,
            :filesystem_importer => Sass::Importers::Filesystem,
            :css_location => "./public/stylesheets",
            :always_update => true,
            :template_location => [["scss", "css"]]
        }.freeze
    
        db = DBI.connect('dbi:ODBC:driver={SQL Server};server=' + $db_host, $db_user, $db_pass)
    
        db.select_all('SELECT name, scope, content FROM ' + $db_name + '.dbo.scss') do | row |
            File.open(Dir.pwd + '/css/' + row['name'] + '.css', 'w') do |css|  
                css.puts Sass::Engine.new(row['content'], SQL_OPTIONS).render
                puts '  overwrite css/' + row['name'] + '.css [db]'
            end
        end
    else
        puts 'ignore database stylesheets, config_ruby doesn\'t exist'
    end
    

    In lib/sass/engine.rb I included this file at the end:

    require File.expand_path(File.dirname(__FILE__) + '../../../sql')
    

    It requires additional dbi and dbd-odbc gems and affects sass –update as well as –watch.

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to make a DataTemplate reference itself just from XAML? In
Is there any way to make it so that the user can scroll along
Is there any way to make a call from within an app without quitting
Is there any way to make a window fixed so that the user can't
Is there any way to make possible to use functions in your file before
Is there any way to make Apache to read PHP documents from RAM? I'm
Is there any way to make all the applications on a server use SQL
Is there any way to make the Tkinter Entry widget so that text can
Is there any way to make the drawer slide from top to bottom?
Is there any way to make the text align left and justify as same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.