System.Data.SQLite

Artifact [46990c6357]
Login

Artifact 46990c6357a5e1ede3a80b313a13fd5f677cd64a:


###############################################################################
#
# common.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

if {[isEagle]} then {
  proc loadAssembly { fileName } {
    set fileName [file join [file dirname $::path] bin \
        [expr {[haveConstraint imageRuntime40] ? "2010" : "2008"}] \
        $::test_configuration bin $fileName]

    if {[catch {set assembly \
        [object load -loadtype File $fileName]}] == 0} then {
      #
      # NOTE: Now, add the necessary test constraint.
      #
      addConstraint [file rootname [file tail $fileName]]

      #
      # NOTE: Return the full path of the loaded file.
      #
      return $fileName
    }

    return ""
  }

  proc setupDb {fileName {mode ""} {varName db}} {
    set fileName [file join [getTemporaryPath] $fileName]
    catch {file delete $fileName}
    upvar 1 $varName db

    set connection {Data Source=${fileName}}

    if {[string length $mode] > 0} then {
      append connection {;Journal Mode=${mode}}
    }

    set db [sql open -type SQLite [subst $connection]]
  }

  proc cleanupDb {fileName {varName db}} {
    upvar 1 $varName db
    catch {sql close $db}
    catch {file delete [file join [getTemporaryPath] $fileName]}
  }
}