This class holds all methods/classes used for database replication purposes.
| 17 | from lib.utils.safe2bin import safechardecode |
| 18 | |
| 19 | class Replication(object): |
| 20 | """ |
| 21 | This class holds all methods/classes used for database |
| 22 | replication purposes. |
| 23 | """ |
| 24 | |
| 25 | def __init__(self, dbpath): |
| 26 | try: |
| 27 | self.dbpath = dbpath |
| 28 | self.connection = sqlite3.connect(dbpath) |
| 29 | self.connection.isolation_level = None |
| 30 | self.cursor = self.connection.cursor() |
| 31 | except sqlite3.OperationalError as ex: |
| 32 | errMsg = "error occurred while opening a replication " |
| 33 | errMsg += "file '%s' ('%s')" % (dbpath, getSafeExString(ex)) |
| 34 | raise SqlmapConnectionException(errMsg) |
| 35 | |
| 36 | class DataType(object): |
| 37 | """ |
| 38 | Using this class we define auxiliary objects |
| 39 | used for representing sqlite data types. |
| 40 | """ |
| 41 | |
| 42 | def __init__(self, name): |
| 43 | self.name = name |
| 44 | |
| 45 | def __str__(self): |
| 46 | return self.name |
| 47 | |
| 48 | def __repr__(self): |
| 49 | return "<DataType: %s>" % self |
| 50 | |
| 51 | class Table(object): |
| 52 | """ |
| 53 | This class defines methods used to manipulate table objects. |
| 54 | """ |
| 55 | |
| 56 | def __init__(self, parent, name, columns=None, create=True, typeless=False): |
| 57 | self.parent = parent |
| 58 | self.name = unsafeSQLIdentificatorNaming(name) |
| 59 | self.columns = columns |
| 60 | if create: |
| 61 | try: |
| 62 | self.execute('DROP TABLE IF EXISTS "%s"' % self.name) |
| 63 | if not typeless: |
| 64 | self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s" %s' % (unsafeSQLIdentificatorNaming(colname), coltype) for colname, coltype in self.columns))) |
| 65 | else: |
| 66 | self.execute('CREATE TABLE "%s" (%s)' % (self.name, ','.join('"%s"' % unsafeSQLIdentificatorNaming(colname) for colname in self.columns))) |
| 67 | except Exception as ex: |
| 68 | errMsg = "problem occurred ('%s') while initializing the sqlite database " % getSafeExString(ex, UNICODE_ENCODING) |
| 69 | errMsg += "located at '%s'" % self.parent.dbpath |
| 70 | raise SqlmapGenericException(errMsg) |
| 71 | |
| 72 | def insert(self, values): |
| 73 | """ |
| 74 | This function is used for inserting row(s) into current table. |
| 75 | """ |
| 76 |
no test coverage detected
searching dependent graphs…