Exemplo n.º 1
0
    def get_schema(self):
        """
        :return:    schema: Dbc.Schema() of data base.

        Parse a xml file to obtain schema.
        """
        schema = Dbc.Schema()

        for an, av in self.xml_repr.documentElement.attributes.items():
            # if an.lower() == "fulltext_engine":
            #     schema.fulltext_engine = av
            # elif an.lower() == "version":
            #     schema.version = av
            # elif an.lower() == "name":
            #     schema.name = av
            # elif an.lower() == "description":
            #     schema.description = av
            if an.lower() == "fulltext_engine":
                pass
            elif an.lower() == "version":
                pass
            elif an.lower() == "name":
                schema.name = av
            elif an.lower() == "description":
                pass
            else:
                raise WrongAttributeException(
                    ["fulltext_engine", "version", "name", "description"], an)
        schema.domains = self.domain_list
        schema.tables = self.tables_list

        return schema
Exemplo n.º 2
0
    def fetch_schema(self):
        schema = Dbc.Schema()
        schema.name = "dbo"

        schema.tables = self.fetch_tables(schema)

        # rsd = list()
        # for domain in schema.domains:
        #     if all([domain != dom for dom in rsd]):
        #         rsd.append(domain)
        # schema.domains = rsd

        return schema
Exemplo n.º 3
0
    def fetch_schema(self):
        schema = Dbc.Schema()
        cursor = self.connection.cursor()

        # sid, name = cursor.execute("""select id, name from dbd$schemas where name = ?""",
        #                            (self.schema_name,)).fetchone()
        # if name is None:
        #     raise SchemaNameError("Can't find schema with {} name".format(self.schema_name))
        # else:
        #     schema.name = name
        schema.domains = self.fetch_domains()
        schema.tables = self.fetch_tables()
        self.connection.commit()
        self.connection.close()
        return schema