提交 20aba66e 编写于 作者: G gongzt

对二进制的sqlite中的files表中的数据进行初始化导入

上级 0badc26d
...@@ -20,6 +20,7 @@ from packageship.application.models.package import BinPack ...@@ -20,6 +20,7 @@ from packageship.application.models.package import BinPack
from packageship.application.models.package import BinRequires from packageship.application.models.package import BinRequires
from packageship.application.models.package import SrcRequires from packageship.application.models.package import SrcRequires
from packageship.application.models.package import BinProvides from packageship.application.models.package import BinProvides
from packageship.application.models.package import BinFiles
from packageship.application.models.package import Packages from packageship.application.models.package import Packages
from packageship import system_config from packageship import system_config
...@@ -60,7 +61,7 @@ class InitDataBase(): ...@@ -60,7 +61,7 @@ class InitDataBase():
} }
self.database_name = None self.database_name = None
self._tables = ['src_pack', 'bin_pack', self._tables = ['src_pack', 'bin_pack',
'bin_requires', 'src_requires', 'bin_provides'] 'bin_requires', 'src_requires', 'bin_provides', 'bin_files']
# Create life cycle related databases and tables # Create life cycle related databases and tables
if not self.create_database(db_name='lifecycle', if not self.create_database(db_name='lifecycle',
tables=['packages_issue', tables=['packages_issue',
...@@ -299,6 +300,7 @@ class InitDataBase(): ...@@ -299,6 +300,7 @@ class InitDataBase():
self._save_bin_packages(db_name) self._save_bin_packages(db_name)
self._save_bin_requires(db_name) self._save_bin_requires(db_name)
self._save_bin_provides(db_name) self._save_bin_provides(db_name)
self._save_bin_files(db_name)
except (SQLAlchemyError, ContentNoneException) as sql_error: except (SQLAlchemyError, ContentNoneException) as sql_error:
LOGGER.logger.error(sql_error) LOGGER.logger.error(sql_error)
self.__del_database(db_name) self.__del_database(db_name)
...@@ -455,6 +457,18 @@ class InitDataBase(): ...@@ -455,6 +457,18 @@ class InitDataBase():
with DBHelper(db_name=db_name) as database: with DBHelper(db_name=db_name) as database:
database.batch_add(provides_datas, BinProvides) database.batch_add(provides_datas, BinProvides)
def _save_bin_files(self, db_name):
self.sql = " select * from files "
files_datas = self.__get_data()
if files_datas is None:
raise ContentNoneException(
'{db_name}:There is no relevant binary file installation\
path data in the provided database '.format(db_name=db_name))
with DBHelper(db_name=db_name) as database:
database.batch_add(files_datas, BinFiles)
def __exists_repeat_database(self): def __exists_repeat_database(self):
""" """
Determine if the same database name exists Determine if the same database name exists
......
...@@ -127,6 +127,17 @@ class BinProvides(DBHelper.BASE): ...@@ -127,6 +127,17 @@ class BinProvides(DBHelper.BASE):
pkgKey = Column(Integer, nullable=True) pkgKey = Column(Integer, nullable=True)
class BinFiles(DBHelper.BASE):
"""
Installation path of the binary package
"""
__tablename__ = 'bin_files'
id = Column(Integer, primary_key=True)
name = Column(String(500), nullable=True)
type = Column(String(50), nullable=True)
pkgKey = Column(Integer)
class Packages(): class Packages():
""" """
Source code package version, issuer and other information Source code package version, issuer and other information
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册