2 # This file is used to create/update/query/erase table for pcds
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
11 from __future__
import absolute_import
12 import Common
.EdkLogger
as EdkLogger
13 from Table
.Table
import Table
14 from Common
.StringUtils
import ConvertToSqlString
18 # This class defined a table used for pcds
20 # @param object: Inherited from object class
23 class TablePcd(Table
):
24 def __init__(self
, Cursor
):
25 Table
.__init
__(self
, Cursor
)
32 # @param ID: ID of a Pcd
33 # @param CName: CName of a Pcd
34 # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
35 # @param Token: Token of a Pcd
36 # @param DatumType: DatumType of a Pcd
37 # @param Model: Model of a Pcd
38 # @param BelongsToFile: The Pcd belongs to which file
39 # @param BelongsToFunction: The Pcd belongs to which function
40 # @param StartLine: StartLine of a Pcd
41 # @param StartColumn: StartColumn of a Pcd
42 # @param EndLine: EndLine of a Pcd
43 # @param EndColumn: EndColumn of a Pcd
46 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
47 CName VARCHAR NOT NULL,
48 TokenSpaceGuidCName VARCHAR NOT NULL,
51 Model INTEGER NOT NULL,
52 BelongsToFile SINGLE NOT NULL,
53 BelongsToFunction SINGLE DEFAULT -1,
54 StartLine INTEGER NOT NULL,
55 StartColumn INTEGER NOT NULL,
56 EndLine INTEGER NOT NULL,
57 EndColumn INTEGER NOT NULL
59 Table
.Create(self
, SqlCommand
)
63 # Insert a record into table Pcd
65 # @param ID: ID of a Pcd
66 # @param CName: CName of a Pcd
67 # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
68 # @param Token: Token of a Pcd
69 # @param DatumType: DatumType of a Pcd
70 # @param Model: Model of a Pcd
71 # @param BelongsToFile: The Pcd belongs to which file
72 # @param BelongsToFunction: The Pcd belongs to which function
73 # @param StartLine: StartLine of a Pcd
74 # @param StartColumn: StartColumn of a Pcd
75 # @param EndLine: EndLine of a Pcd
76 # @param EndColumn: EndColumn of a Pcd
78 def Insert(self
, CName
, TokenSpaceGuidCName
, Token
, DatumType
, Model
, BelongsToFile
, BelongsToFunction
, StartLine
, StartColumn
, EndLine
, EndColumn
):
80 (CName
, TokenSpaceGuidCName
, DatumType
) = ConvertToSqlString((CName
, TokenSpaceGuidCName
, DatumType
))
81 SqlCommand
= """insert into %s values(%s, '%s', '%s', %s, '%s', %s, %s, %s, %s, %s, %s, %s)""" \
82 % (self
.Table
, self
.ID
, CName
, TokenSpaceGuidCName
, Token
, DatumType
, Model
, BelongsToFile
, BelongsToFunction
, StartLine
, StartColumn
, EndLine
, EndColumn
)
83 Table
.Insert(self
, SqlCommand
)