(db, table, values)
| 100 | raise ValueError("Action not found in sequence") |
| 101 | |
| 102 | def add_data(db, table, values): |
| 103 | v = db.OpenView("SELECT * FROM `%s`" % table) |
| 104 | count = v.GetColumnInfo(MSICOLINFO_NAMES).GetFieldCount() |
| 105 | r = CreateRecord(count) |
| 106 | for value in values: |
| 107 | assert len(value) == count, value |
| 108 | for i in range(count): |
| 109 | field = value[i] |
| 110 | if isinstance(field, int): |
| 111 | r.SetInteger(i+1,field) |
| 112 | elif isinstance(field, str): |
| 113 | r.SetString(i+1,field) |
| 114 | elif field is None: |
| 115 | pass |
| 116 | elif isinstance(field, Binary): |
| 117 | r.SetStream(i+1, field.name) |
| 118 | else: |
| 119 | raise TypeError("Unsupported type %s" % field.__class__.__name__) |
| 120 | try: |
| 121 | v.Modify(MSIMODIFY_INSERT, r) |
| 122 | except Exception: |
| 123 | raise MSIError("Could not insert "+repr(values)+" into "+table) |
| 124 | |
| 125 | r.ClearData() |
| 126 | v.Close() |
| 127 | |
| 128 | |
| 129 | def add_stream(db, name, path): |
no test coverage detected