Hi Everyone,<br> <br>    I am using sqlite3 with python2.5 and the pysqlite wrapper. I am trying to copy tables from one database (in memory) to another database (file) using ATTACH. I looked on the internet and found a couple of sites that show how to do this but the table schema is not copied.  <br>
 <br>def SaveToFile(self,filename):<br>        # Attach external db file - give it handle filename<br>        # Attaching automatically creates a database by default<br>        self.__curs.execute("ATTACH %s AS %s" % (filename,filename))   <br>
        table_names=self.__curs.execute("SELECT name FROM main.sqlite_master WHERE type='table'").fetchall()<br>        for table_name, in table_names:<br>            #copy in mem db to persistent db<br>
            self.__curs.execute("CREATE TABLE %s.%s AS SELECT * FROM main.%s" % (filename,table_name,table_name))     <br>        self.__curs.execute("DETACH %s" % filename)  # Detach external db"""<br>
 <br> <br>Is there a way to copy the schema from the sqlite_master table.  I know we can used iter.dump from within python to dump to text based SQL but I would prefer not to do this.  Eventually my goal is to dynamically load and unload sections of a file based database (could be tables or rows) in and out of memory for effeciency purposes.  Any help is appreciated. Thanks in advance.<br>
 <br>Denis