コード例 #1
0
ファイル: file.py プロジェクト: henkelund/memobox
    def _install(cls):
        """Install base table and attributes"""

        DeviceModel.install()
        ExtendedModel.install()
        table = DBHelper.quote_identifier(cls._table)
        pk = DBHelper.quote_identifier(cls._pk)

        return (
            lambda: (
                DBHelper().query("""
                    CREATE TABLE %s (
                        %s           INTEGER PRIMARY KEY AUTOINCREMENT,
                        "name"       TEXT    NOT NULL DEFAULT '',
                        "abspath"    TEXT    NOT NULL DEFAULT '',
                        "extension"  TEXT,
                        "type"       TEXT    NOT NULL DEFAULT '',
                        "subtype"    TEXT    NOT NULL DEFAULT '',
                        "charset"    TEXT,
                        "checksum"   TEXT    NOT NULL DEFAULT '',
                        "size"       INTEGER,
                        "created_at" INTEGER,
                        "indexed_at" INTEGER,
                        "is_hidden"  INTEGER NOT NULL DEFAULT 0,
                        "rating"     INTEGER NOT NULL DEFAULT 0,
                        "device"     INTEGER,
                        "devpath"    TEXT    NOT NULL DEFAULT '',
                        FOREIGN KEY ("device") REFERENCES "device"("_id")
                            ON DELETE SET NULL ON UPDATE SET NULL
                    )
                """ % (table, pk)),
                DBHelper().query("""
                    CREATE UNIQUE INDEX "UNQ_FILE_DUPLICATE"
                        ON %s ("name", "devpath", "checksum")
                """ % table),
                cls._create_attribute_tables(),
                cls._create_attribute(
                    'width', 'Width', 'integer', 'Image'),
                cls._create_attribute(
                    'height', 'Height', 'integer', 'Image'),
                cls._create_attribute(
                    'latitude', 'Latitude', 'real', 'Image'),
                cls._create_attribute(
                    'longitude', 'Longitude', 'real', 'Image'),
                cls._create_attribute(
                    'timestamp', 'Timestamp', 'integer', 'Image'),
                cls._create_attribute(
                    'orientation', 'Orientation', 'integer', 'Image')
            ),
        )
コード例 #2
0
ファイル: file.py プロジェクト: henkelund/memobox
    def _install(cls):
        """Install base table and attributes"""

        DeviceModel.install()
        ExtendedModel.install()
        table = DBHelper.quote_identifier(cls._table)
        pk = DBHelper.quote_identifier(cls._pk)

        return (
            lambda:
            (DBHelper().query("""
                    CREATE TABLE %s (
                        %s           INTEGER PRIMARY KEY AUTOINCREMENT,
                        "name"       TEXT    NOT NULL DEFAULT '',
                        "abspath"    TEXT    NOT NULL DEFAULT '',
                        "extension"  TEXT,
                        "type"       TEXT    NOT NULL DEFAULT '',
                        "subtype"    TEXT    NOT NULL DEFAULT '',
                        "charset"    TEXT,
                        "checksum"   TEXT    NOT NULL DEFAULT '',
                        "size"       INTEGER,
                        "created_at" INTEGER,
                        "indexed_at" INTEGER,
                        "is_hidden"  INTEGER NOT NULL DEFAULT 0,
                        "rating"     INTEGER NOT NULL DEFAULT 0,
                        "device"     INTEGER,
                        "devpath"    TEXT    NOT NULL DEFAULT '',
                        FOREIGN KEY ("device") REFERENCES "device"("_id")
                            ON DELETE SET NULL ON UPDATE SET NULL
                    )
                """ % (table, pk)), DBHelper().query("""
                    CREATE UNIQUE INDEX "UNQ_FILE_DUPLICATE"
                        ON %s ("name", "devpath", "checksum")
                """ % table), cls._create_attribute_tables(),
             cls._create_attribute('width', 'Width', 'integer', 'Image'),
             cls._create_attribute('height', 'Height', 'integer', 'Image'),
             cls._create_attribute('latitude', 'Latitude', 'real', 'Image'),
             cls._create_attribute('longitude', 'Longitude', 'real', 'Image'),
             cls._create_attribute('timestamp', 'Timestamp', 'integer', 'Image'
                                   ),
             cls._create_attribute('orientation', 'Orientation', 'integer',
                                   'Image')), )
コード例 #3
0
    def _install(cls):
        """Install base table and attributes"""

        ExtendedModel.install()
        table = DBHelper.quote_identifier(cls._table)

        return (
            lambda:
            (DBHelper().query("""
                    CREATE TABLE %s (
                        "_id"    INTEGER PRIMARY KEY AUTOINCREMENT,
                        "static" TEXT NOT NULL DEFAULT ''
                    )
                """ % table), SampleExtModel._create_attribute_tables(),
             SampleExtModel._create_attribute(
                 'sample_attr_1', 'Sample Attribute #1', 'integer', 'Default'),
             SampleExtModel._create_attribute(
                 'sample_attr_2', 'Sample Attribute #2', 'text', 'Default'),
             SampleExtModel._create_attribute(
                 'sample_attr_3', 'Sample Attribute #3', 'real', 'Not Default')
             ), )
コード例 #4
0
ファイル: test_extended.py プロジェクト: henkelund/memobox
    def _install(cls):
        """Install base table and attributes"""

        ExtendedModel.install()
        table = DBHelper.quote_identifier(cls._table)

        return (
            lambda: (
                DBHelper().query("""
                    CREATE TABLE %s (
                        "_id"    INTEGER PRIMARY KEY AUTOINCREMENT,
                        "static" TEXT NOT NULL DEFAULT ''
                    )
                """ % table),
                SampleExtModel._create_attribute_tables(),
                SampleExtModel._create_attribute(
                    'sample_attr_1', 'Sample Attribute #1', 'integer', 'Default'),
                SampleExtModel._create_attribute(
                    'sample_attr_2', 'Sample Attribute #2', 'text', 'Default'),
                SampleExtModel._create_attribute(
                    'sample_attr_3', 'Sample Attribute #3', 'real', 'Not Default')
            ),
        )