예제 #1
0
파일: driver.py 프로젝트: v-legoff/pa-poc3
 def add_table(self, table):
     """Add the new table."""
     Driver.add_table(self, table)
     name = table.name
     self.collections[name] = self.datas[name]
     self.inc_collections[name] = self.increments[name]
     self.line_ids[name] = {}
예제 #2
0
파일: driver.py 프로젝트: v-legoff/pa-poc3
    def add_table(self, table):
        """Add the new table if it doesn't exist."""
        Driver.add_table(self, table)
        name = table.name
        filename = self.location + "/" + name + ".yml"
        self.files[name] = filename
        if os.path.exists(filename):
            with open(filename, "r") as file:
                return self.read_table(name, file)

        return []
예제 #3
0
파일: driver.py 프로젝트: v-legoff/pa-poc3
    def add_table(self, table):
        """Add the new table if it doesn't exist."""
        name = table.name
        existing_tables = list(self.tables.keys())
        Driver.add_table(self, table)
        self.tables[name] = table
        if name not in existing_tables:
            fields = table.fields
            sql_fields = []
            for field_name, constraint in fields.items():
                instruction = self.instruction_create_field(field_name,
                        constraint)
                sql_fields.append(instruction)

            query = "CREATE TABLE {} ({})".format(name, ", ".join(sql_fields))
            self.execute_query(query)