# -*- coding: utf-8 -*-################################################################################ Copyright (c) 2019 Zope Foundation and Contributors.# All Rights Reserved.## This software is subject to the provisions of the Zope Public License,# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS# FOR A PARTICULAR PURPOSE.###############################################################################from__future__importabsolute_importfrom__future__importdivisionfrom__future__importprint_functionimportos.pathfromzope.interfaceimportimplementerfrom..interfacesimportISchemaInstallerfrom..schemaimportAbstractSchemaInstaller
[docs]@implementer(ISchemaInstaller)classSqlite3SchemaInstaller(AbstractSchemaInstaller):COLTYPE_OID_TID='INTEGER'COLTYPE_BINARY_STRING='BLOB'COLTYPE_STATE='BLOB'COLTYPE_BLOB_CHUNK_NUM='INTEGER'COLTYPE_BLOB_CHUNK='BLOB'COLTYPE_MD5='BLOB'all_tables=tuple(tfortinAbstractSchemaInstaller.all_tablesift!='new_oid')def__init__(self,driver,oid_allocator,**kwargs):self.driver=driverself.oid_allocator=oid_allocatorsuper().__init__(**kwargs)defget_database_name(self,cursor):returnos.path.splitext(os.path.basename(self.connmanager.path))[0]deflist_tables(self,cursor):cursor.execute('SELECT name FROM sqlite_master ''WHERE type = "table"')return[x[0]forxincursor.fetchall()]deflist_views(self,cursor):cursor.execute('SELECT name FROM sqlite_master ''WHERE type = "view"')return[x[0]forxincursor.fetchall()]deflist_procedures(self,cursor):return()list_sequences=list_proceduresdef_create_pack_lock(self,cursor):"""Does nothing."""def_reset_oid(self,cursor):self.oid_allocator.reset_oid()