(self, cmd)
read FILENAME: Processes SQL and commands in FILENAME (or Python if FILENAME ends with .py)

        Treats the specified file as input (a mixture or SQL and/or
        dot commands).  If the filename ends in .py then it is treated
        as Python code instead.

        For Python code the symbol 'shell' refers to the instance of
        the shell and 'apsw' is the apsw module.
read FILENAME: Processes SQL and commands in FILENAME (or Python if FILENAME ends with .py)
read FILENAME : Processes SQL and commands in FILENAME ( or Python if FILENAME ends with . py )
def command_read(self, cmd):
        """read FILENAME: Processes SQL and commands in FILENAME (or Python if FILENAME ends with .py)

        Treats the specified file as input (a mixture or SQL and/or
        dot commands).  If the filename ends in .py then it is treated
        as Python code instead.

        For Python code the symbol 'shell' refers to the instance of
        the shell and 'apsw' is the apsw module.
        """
        if len(cmd) != 1:
            raise self.Error("read takes a single filename")
        if cmd[0].lower().endswith(".py"):
            g = {}
            g.update({'apsw': apsw, 'shell': self})
            if sys.version_info < (3, 0):
                execfile(cmd[0], g, g)
            else:
                # compile step is needed to associate name with code
                f=open(cmd[0])
                try:
                    exec(compile(f.read(), cmd[0], 'exec'), g, g)
                finally:
                    f.close()
        else:
            f = codecs.open(cmd[0], "r", self.encoding[0])
            try:
                try:
                    self.push_input()
                    self.stdin = f
                    self.interactive = False
                    self.input_line_number = 0
                    while True:
                        line = self.getcompleteline()
                        if line is None:
                            break
                        self.process_complete_line(line)
                except:
                    eval = sys.exc_info()[1]
                    if not isinstance(eval, SystemExit):
                        self._append_input_description()
                    raise

            finally:
                self.pop_input()
                f.close()
def command_read ( self , cmd ) : if len ( cmd ) != 1 : raise self . Error ( "read takes a single filename" ) if cmd [ 0 ] . lower ( ) . endswith ( ".py" ) : g = { } g . update ( { 'apsw' : apsw , 'shell' : self } ) if sys . version_info < ( 3 , 0 ) : execfile ( cmd [ 0 ] , g , g ) else : # compile step is needed to associate name with code f = open ( cmd [ 0 ] ) try : exec ( compile ( f . read ( ) , cmd [ 0 ] , 'exec' ) , g , g ) finally : f . close ( ) else : f = codecs . open ( cmd [ 0 ] , "r" , self . encoding [ 0 ] ) try : try : self . push_input ( ) self . stdin = f self . interactive = False self . input_line_number = 0 while True : line = self . getcompleteline ( ) if line is None : break self . process_complete_line ( line ) except : eval = sys . exc_info ( ) [ 1 ] if not isinstance ( eval , SystemExit ) : self . _append_input_description ( ) raise finally : self . pop_input ( ) f . close ( )