blob: a2cf785cbb91e9f4ca85db4dfd27bb8bb6690ed2 [file] [log] [blame]
fmenozzib4f254e2016-06-28 14:03:03 -07001#!/usr/bin/env python
2#
3# Copyright 2015 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8import argparse
9import sqlite3
10
11def create_database(inpath, outpath):
12 with sqlite3.connect(outpath) as conn:
13 c = conn.cursor();
14 c.execute('''CREATE TABLE IF NOT EXISTS gradients (
15 ColorCount INTEGER,
16 GradientType TEXT,
17 TileMode TEXT,
18 EvenlySpaced INTEGER,
19 HardStops INTEGER,
20 Positions TEXT
21 )''');
22 c.execute("DELETE FROM gradients");
23
24 with open(inpath, "r") as results:
25 gradients = []
26 for line in [line.strip() for line in results]:
27 gradients.append(line.split());
28
29 c.executemany("INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?)",
30 gradients);
31
32 conn.commit();
33
34
35if __name__ == "__main__":
36 parser = argparse.ArgumentParser(
37 description = "Transform Lua script output to a SQL DB");
38 parser.add_argument("inpath", help="Path to Lua script output file");
39 parser.add_argument("outpath", help="Path to SQL DB");
40 args = parser.parse_args();
41
42 create_database(args.inpath, args.outpath);