lib/sportdb/models.rb in sportdb-models-1.11.0 vs lib/sportdb/models.rb in sportdb-models-1.11.1
- old
+ new
@@ -220,10 +220,19 @@
puts "Connecting to db using settings: "
pp config
ActiveRecord::Base.establish_connection( config )
# ActiveRecord::Base.logger = Logger.new( STDOUT )
+
+ ## if sqlite3 add (use) some pragmas for speedups
+ if config[:adapter] == 'sqlite3'
+ ## check/todo: if in memory e.g. ':memory:' no pragma needed!!
+ con = ActiveRecord::Base.connection
+ con.execute( 'PRAGMA synchronous=OFF;' )
+ con.execute( 'PRAGMA journal_mode=OFF;' )
+ con.execute( 'PRAGMA temp_store=MEMORY;' )
+ end
end
def self.setup_in_memory_db
@@ -244,6 +253,6 @@
end # module SportDb
## say hello
-puts SportDb.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
+puts SportDb.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG