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] = {}
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 []
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)