示例#1
0
    def dbd_to_ram(self):
        conn = sqlite3.connect(self.file_path)
        cur = conn.cursor()

        db_schema = cur.execute("SELECT * from dbd$schemas").fetchall()
        schema_metadata = self._getMetadata(cur, "dbd$schemas")

        for item in db_schema:
            schema_dictionary = dict(zip(schema_metadata, list(item)))
            schema = Schema(schema_dictionary)
            schema.domains = self._getDbDomains(cur)

            if schema_dictionary.get("id") is not None:
                schema.tables = self._getDbTables(cur, schema_dictionary["id"])

        conn.commit()
        conn.close()

        return schema
示例#2
0
    def xml_to_ram(self):
        schema = Schema()
        for attributeName, attributeValue in self.xml.documentElement.attributes.items(
        ):
            if attributeName.lower() == "fulltext_engine":
                schema.fulltext_engine = attributeValue
            elif attributeName.lower() == "version":
                schema.version = attributeValue
            elif attributeName.lower() == "name":
                schema.name = attributeValue
            elif attributeName.lower() == "description":
                schema.description = attributeValue
            else:
                raise ValueError(
                    "Incorrect attribute name \"{}\" in tag \"{}\"".format(
                        attributeName, schema.nodeName))

            schema.domains = self._getDomains()
            schema.tables = self._getTables(self.xml)

        return schema