Skip to main content

No project description provided

Project description

database-extractor

Description

This project intends to create a python package to extract the content of a database and convert it into a python object. For the moment, this package can only extract the content of SQLite3 databases.

In this implementation, a row is represented as a python dictionary object.

Since the goal of this package is to extract the content of a database, BLOB fields will be decoded if possible if they represent a protobuf or a json. In order to facilitate the data readability, nested protobuf/json objects will be converted to unidimensional objects (cf. image below).

Example of nested-object conversion to unidimensional object

Export format

A database can be exported as a JSON or as an XML at the moment. A short exemple of both implementation is given below.

XML

<?xml version='1.0' encoding='utf-8'?>
<database name="resources/dummy.db">
    <table name="Tab1">
        <row>
            <column type="str" key="userId" value="C2V6" />
            <column type="NoneType" key="convId" value="None" />
            <column type="str" key="sent" value="0" />
        </row>
    </table>
    <table name="Tab2">
        <row>
            <column type="str" key="convId" value="uaz-57" />
            <column type="int" key="messageId" value="1" />
            <column type="str" key="extKey" value="chat" />
        </row>
        <row>
            <column type="str" key="convId" value="r2d-2a" />
            <column type="int" key="messageId" value="3" />
            <column type="str" key="extKey" value="27FwAPH4QapLXF5fhDcs7" />
        </row>
        <row>
            <column type="str" key="convId" value="av7-dp" />
            <column type="int" key="messageId" value="5" />
            <column type="bytes" key="extKey" value="0000040f" />
        </row>
    </table>
</database>

JSON

{
    "resources/dummy.db": {
        "Tab1": [
            {
                "userId": {
                    "value": "C2V6",
                    "type": "str"
                },
                "convId": {
                    "value": null,
                    "type": "NoneType"
                },
                "sent": {
                    "value": 0,
                    "type": "int"
                }
            }
        ],
        "Tab2": [
            {
                "convId": {
                    "value": "uaz-57",
                    "type": "str"
                },
                "messageId": {
                    "value": 1,
                    "type": "int"
                },
                "extKey": {
                    "value": "chat",
                    "type": "str"
                }
            },
            {
                "convId": {
                    "value": "r2d-2a",
                    "type": "str"
                },
                "messageId": {
                    "value": 3,
                    "type": "int"
                },
                "extKey": {
                    "value": "27FwAPH4QapLXF5fhDcs7",
                    "type": "str"
                }
            },
            {
                "convId": {
                    "value": "av7-dp",
                    "type": "str"
                },
                "messageId": {
                    "value": 5,
                    "type": "int"
                },
                "extKey": {
                    "value": "0000040f",
                    "type": "bytes"
                }
            }
        ]
    }
}

Example

from database_converter.converters.sqlite3.db import SQLite3DatabaseFileConverter
import database_converter.writers.json as json
import database_converter.writers.xml as xml

if __name__ == '__main__':
    # Convert the content of the database into a python object
    extractor = SQLite3DatabaseFileConverter('DB1.db')
    content = extractor.convert()

    # Save as a XML
    xml.write('extraction.xml', content)
    # Save as a JSON
    json.write('extraction.json', content)

Features to implement

  • extractors: sqlite3 WAL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

database_converter-0.0.6.tar.gz (145.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

database_converter-0.0.6-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file database_converter-0.0.6.tar.gz.

File metadata

  • Download URL: database_converter-0.0.6.tar.gz
  • Upload date:
  • Size: 145.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for database_converter-0.0.6.tar.gz
Algorithm Hash digest
SHA256 241c6d1c6288a0b97cd693765db1ba9e08af905a414485a46c2d90922501ceb9
MD5 7e2944e8110c6b14d101e61c3b96222b
BLAKE2b-256 4cd333194e3d8c424eca789c326d1cc596ceb34d6d3b698a63756f6e72dbb4af

See more details on using hashes here.

File details

Details for the file database_converter-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for database_converter-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dd5fd86793e1e7e2b92e0b1760987cdf26ac5b112b868072304e482f459987b9
MD5 f7a056b9eab613a6f904e1f2af4531da
BLAKE2b-256 55d4cac1ba479b03438e1ad90e15404b50ac3964ef3d7599b114039ef7268275

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page