I use Ruby. In the following example I use a replacement tag "#{lvl}" in
the scripts. For each of the levels (indv,hhld,resi), I do a substitution
against the script and pass the script to sqlite.
dbname =
File.join('d:','cloveretl','projects','test_ii','data-out-97','test.db')
db = SQLite3::Database.new(dbname)
script_folder = File.join(prj.ps_project_folder,'scripts')
scripts_to_run = [
'02_build_relationships.sql',
'05_cdi_perspective.sql',
'05_itrack_perspective.sql',
'10_cdi_select',
'10_itrack_select'
]
['indv','hhld','resi'].each {|lvl|
puts "Executing level: #{lvl}"
scripts_to_run.each {|sql|
puts " script: #{sql}"
script = File.open(File.join(script_folder,sql)).readlines(sep=nil)[0]
db.execute_batch(script.gsub('#{lvl}',lvl))
}
}
On Fri, Jun 15, 2012 at 5:01 AM, Niall O'Reilly <[email protected]>wrote:
>
> On 15 Jun 2012, at 10:45, Udi Karni wrote:
>
> > Niall - thanks. If I understand correctly - you use bash to do the
> > preprocessing of the substitutions and submit the prepared statements to
> > Sqlite.
>
> Well, 'prepared' is not the term I would use, as it has a specific
> meaning in the context of SQLite (or other SQL implementations).
>
> Bash does make substitutions in the 'pre-scripted' (for want of a
> better term) block delimited by '<<EOF' and 'EOF' before passing
> the modified text to sqlite3 as input. I understand that other
> shells can do likewise, but bash is the one I'm familiar with.
>
> So, yes and no ... 8-)
>
> Good luck!
> Niall O'Reilly
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users