def write(self, _force=False, _exists_ok=False, **items):
if self.fname and self.fname.exists():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>with self.connection() as db:<EOL><INDENT>for table in self.tables:<EOL><INDENT>db.execute(table.sql(translate=self.translate))<EOL><DEDENT>db.execute('<STR_LIT>')<EOL>db.commit()<EOL>refs = defaultdict(list)  <EOL>for t in self.tables:<EOL><INDENT>if t.name not in items:<EOL><INDENT>continue<EOL><DEDENT>rows, keys = [], []<EOL>cols = {c.name: c for c in t.columns}<EOL>for i, row in enumerate(items[t.name]):<EOL><INDENT>pk = row[t.primary_key[<NUM_LIT:0>]]if t.primary_key and len(t.primary_key) == <NUM_LIT:1> else None<EOL>values = []<EOL>for k, v in row.items():<EOL><INDENT>if k in t.many_to_many:<EOL><INDENT>assert pk<EOL>at = t.many_to_many[k]<EOL>atkey = tuple([at.name] + [c.name for c in at.columns])<EOL>for vv in v:<EOL><INDENT>fkey, context = self.association_table_context(t, k, vv)<EOL>refs[atkey].append((pk, fkey, context))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>col = cols[k]<EOL>if isinstance(v, list):<EOL><INDENT>v = (col.separator or '<STR_LIT:;>').join(<EOL>col.convert(vv) for vv in v)<EOL><DEDENT>else:<EOL><INDENT>v = col.convert(v) if v is not None else None<EOL><DEDENT>if i == <NUM_LIT:0>:<EOL><INDENT>keys.append(col.name)<EOL><DEDENT>values.append(v)<EOL><DEDENT><DEDENT>rows.append(tuple(values))<EOL><DEDENT>insert(db, self.translate, t.name, keys, *rows)<EOL><DEDENT>for atkey, rows in refs.items():<EOL><INDENT>insert(db, self.translate, atkey[<NUM_LIT:0>], atkey[<NUM_LIT:1>:], *rows)<EOL><DEDENT>db.commit()<EOL><DEDENT>
Creates a db file with the core schema.

:param force: If `True` an existing db file will be overwritten.