CN112506488A - Method for generating programming language class based on sql creating statement - Google Patents

Method for generating programming language class based on sql creating statement Download PDF

Info

Publication number
CN112506488A
CN112506488A CN202011275042.8A CN202011275042A CN112506488A CN 112506488 A CN112506488 A CN 112506488A CN 202011275042 A CN202011275042 A CN 202011275042A CN 112506488 A CN112506488 A CN 112506488A
Authority
CN
China
Prior art keywords
sql
programming language
variable
statements
classes based
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011275042.8A
Other languages
Chinese (zh)
Inventor
孙保权
王金刚
段凌云
王振兴
吴奇
陈正超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guiyang Yuwan Technology Co ltd
Original Assignee
Guiyang Yuwan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guiyang Yuwan Technology Co ltd filed Critical Guiyang Yuwan Technology Co ltd
Priority to CN202011275042.8A priority Critical patent/CN112506488A/en
Publication of CN112506488A publication Critical patent/CN112506488A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method for generating a programming language class based on sql creating statements, which comprises the following steps: s1, putting the sql creating statement into a text file, and transmitting programming language parameters needing to be generated; s2, obtaining an sql analysis rule by utilizing multiple experiments; s3, analyzing the variable type through sql analysis rule matching; s4, acquiring the required real data type; and S5, formatting and splicing the variable names and the converted data types, and writing the spliced contents into a text file to obtain the required model files. The method and the device quickly generate the model classes required by different programming languages according to the transmitted sql creating statements, are very efficient and convenient, replace manual writing work, can reduce a lot of repeated operations, and simplify the work in program development.

Description

Method for generating programming language class based on sql creating statement
Technical Field
The invention relates to a method, in particular to a method for generating a programming language class based on sql creating statements.
Background
At present, in program development, a plurality of functional modules are needed, a plurality of model classes need to be defined and written, and one class contains a plurality of attributes, so that the writing workload is large. At present, manual writing is mostly adopted, and related model classes are defined according to requirements, but in daily development, manual definition is needed each time, which is troublesome and labor-consuming, and is very tedious and slow; particularly, when a complex class appears, more than ten attributes exist, which causes the writing process to be very slow; these problems are more pronounced in complex large projects.
Disclosure of Invention
In order to solve the defects of the technology, the invention provides a method for generating programming language classes based on sql creating statements.
In order to solve the technical problems, the invention adopts the technical scheme that: a method for generating programming language classes based on sql creating statements is characterized in that: the method comprises the following steps:
s1, putting the sql creating statement into a text file, and transmitting programming language parameters needing to be generated;
s2, obtaining an sql analysis rule by utilizing multiple experiments;
s3, analyzing the variable type through sql analysis rule matching;
s4, acquiring real data types used by different programming languages;
and S5, after formatting and splicing, writing the spliced contents into a text file to obtain the required model file.
Further, in S2, the variable name and the data type of the variable are identified by the common definition table structure syntax in sql, so as to obtain a template format of the created statement, and then the template format is analyzed, so as to obtain an sql analysis rule.
Further, the sql resolves the rule into a regular expression.
Further, the obtained creation statement is in a template format of 'variable' + space + data type, and is reflected in that the regular expression is: v "(? Where the first term, (.
Further, in S3, the program reads the content of the sql create statement file, and the variable type of the data table is parsed by sql parsing rule matching.
Further, the variable type is key information of the data table, including a table name of the data table, a variable name and a data type of each row, and annotation information. Further, in S4, loading a corresponding type mapping configuration table according to the matched variable type, to obtain the real data types used by different programming languages.
Further, in S5, the specific process of formatting the concatenation is: and splicing the character strings of the variable names and the converted data types, adding corresponding tab tabulation symbols and line feed symbols after splicing each line, adjusting the output style, and writing the spliced contents into a text file to obtain the required model file.
The invention discloses a method for generating programming language classes based on sql creating statements, which is very efficient and convenient to rapidly generate model classes required by different programming languages according to the transmitted sql creating statements, can replace tedious and time-consuming manual writing work, automatically generates the model classes with standard output formats in a program, can reduce a lot of repeated operations, and simplifies the work in program development.
Drawings
FIG. 1 is a schematic overall flow chart of the present invention.
FIG. 2 is a schematic flow chart of an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
The invention discloses a method for generating a programming language class based on sql creating statements, which comprises the following steps as shown in figure 1:
s1, putting the sql creating statement into a text file, and transmitting programming language parameters needing to be generated;
s2, obtaining an sql analysis rule by utilizing multiple experiments;
s3, analyzing the variable type through sql analysis rule matching;
s4, acquiring real data types used by different programming languages;
and S5, after formatting and splicing, writing the spliced contents into a text file to obtain the required model file.
According to the method for generating the programming language class based on the sql creating statement, disclosed by the invention, the model classes required by different programming languages are quickly generated according to the incoming sql creating statement. Firstly, a user needs to put an sql creating statement into a text file and input programming language parameters needing to be generated. Then, after analyzing the common creation statements of data types such as char, varchar, int, datatime and the like for many times, obtaining a template format of the creation statements of' variable + space + data type, and reflecting that the regular expression is: v "(? V, where the first term is the name of the variable matching each resolved line, \\ s is a space, and after the space (; for example, the following sql statement: CREATE TABLE' poletics ` (
`id`int unsigned NOT NULL AUTO_INCREMENT,
`group`varchar(255)CHARACTER SET utf8mb4 DEFAULT NULL,
`user`varchar(255)CHARACTER SET utf8mb4 DEFAULT NULL,
`resource`varchar(255)CHARACTER SET utf8mb4 DEFAULT NULL,
`action`varchar(255)CHARACTER SET utf8mb4 DEFAULT NULL,
PRIMARY KEY(`id`)
)ENGINE=InnoDB AUTO_INCREMENT DEFAULT CHARSET=utf8mb4
The program reads the content of the sql create statement file, via/"(? Performing pattern matching for each row, the following effects can be obtained:
id->int,group->varchar,user->varchar,resource->varchar,action->varchar,
then mapping to different real data types used for changing into languages according to the matched variable types, such as int corresponding to int type in sql, char corresponding to string type in sql, and the like, and acquiring the required real data types; and finally, carrying out formatting splicing on the variable names and the converted data types, adjusting the output style, and writing the spliced contents into a text file to obtain the required model file.
The method for generating programming language classes based on sql create statements disclosed by the present invention is further described in detail below with reference to fig. 2.
A method for generating a programming language class based on sql create statements, as shown in fig. 2, includes the following steps:
s1, putting the sql creating statement into the text file, and transmitting the programming language parameters needing to be generated.
S2, obtaining a template format with a creation statement of 'variable' + space + data type by using multiple experiments, and analyzing according to the template format with the 'variable' + space + data type to obtain a regular expression.
The method specifically comprises the following steps: identifying that the content in the' character is a variable name and the following content is the data type of the variable through common definition table structure grammars such as create table, char, varchar, int assigned and the like in sql; after the common creation sentences of data types such as char, varchar, int, datatime and the like are contrastively analyzed, a template format with the creation sentences as' variable + space + data types is obtained, and the template format is reflected that the regular expression is as follows: v "(? Where the first term, (.
S3, reading the content of the sql statement creating file by a program, and analyzing the table name of the database, the variable name of each line and the data type through regular expression matching; through the rule of the regular expression, the key information of the table name (obtained by analyzing the content after the keyword of the create table), the variable name, the data type (obtained by analyzing the content after the symbol) and the comment (obtained by explaining the content after the comment keyword) of the data table can be accurately and quickly matched, and part of codes are as follows:
Figure BDA0002779451410000041
s4, mapping the matched variable types to real data types used by corresponding different programming languages to obtain the required real data types; the program loads the corresponding configuration files of the corresponding programming language data type and the database type according to the appointed programming language, and the required real data type is obtained; part of the code is as follows:
Figure BDA0002779451410000051
s5, finally, removing underlines and other special characters from the parsed data table name, converting each name into a class name which accords with common specifications from capitalization, circularly traversing the variable list, performing formatting splicing on the variable name and the converted data type, writing the spliced content into a text file, and outputting and generating a required model class file; the specific process of formatted splicing is as follows: character string splicing is carried out on the variable names and the converted data types, after each line is spliced, corresponding tab tabulation symbols and line feed symbols are added, the output style is adjusted, and the spliced contents are written into a text file to obtain a required model file; part of the code is as follows:
Figure BDA0002779451410000052
Figure BDA0002779451410000061
in the process of project development, a large number of functional modules are needed to be written, grammars used by each group of programming languages are different, and variable names of the model classes and table field names in a database are often the same, so that the method for generating the programming language classes based on the sql creating statements disclosed by the invention can quickly generate the model classes needed by different programming languages according to the transmitted sql creating statements, is very efficient and convenient, can reduce a large number of repeated operations, can replace the traditional manual writing work which is still tedious and time-consuming, can automatically generate the model classes with standard output formats by transmitting related programming language parameters, and simplifies the work in program development.
The above embodiments are not intended to limit the present invention, and the present invention is not limited to the above examples, and those skilled in the art may make variations, modifications, additions or substitutions within the technical scope of the present invention.

Claims (8)

1. A method for generating programming language classes based on sql creating statements is characterized in that: the method comprises the following steps:
s1, putting the sql creating statement into a text file, and transmitting programming language parameters needing to be generated;
s2, obtaining an sql analysis rule by utilizing multiple experiments;
s3, analyzing the variable type through sql analysis rule matching;
s4, acquiring real data types used by different programming languages;
and S5, after formatting and splicing, writing the spliced contents into a text file to obtain the required model file.
2. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: in S2, the variable name and the data type of the variable are identified by the common definition table structure syntax in sql to obtain a template format of the created statement, and then the template format is analyzed to obtain sql analysis rules.
3. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: and the sql parsing rule is a regular expression.
4. The method of generating programming language classes based on sql create statements as claimed in claim 3, characterized in that: the obtained creation statement is a template format of 'variable' plus space + data type, and is reflected that the regular expression is: is/' (? Where the first term (..
5. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: in S3, the program reads the content of the sql create statement file, and the variable type of the data table is resolved through sql parsing rule matching.
6. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: the variable type is key information of the data table, and comprises a table name of the data table, a variable name and data type of each row and annotation information.
7. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: in S4, loading a corresponding type mapping configuration table according to the matched variable type, and obtaining the real data types used by different programming languages.
8. The method of generating programming language classes based on sql create statements as claimed in claim 1, characterized in that: in S5, the specific process of formatting and splicing is as follows: and splicing the character strings of the variable names and the converted data types, adding corresponding tab tabulation symbols and line feed symbols after splicing each line, adjusting the output style, and writing the spliced contents into a text file to obtain the required model file.
CN202011275042.8A 2020-11-16 2020-11-16 Method for generating programming language class based on sql creating statement Pending CN112506488A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011275042.8A CN112506488A (en) 2020-11-16 2020-11-16 Method for generating programming language class based on sql creating statement

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011275042.8A CN112506488A (en) 2020-11-16 2020-11-16 Method for generating programming language class based on sql creating statement

Publications (1)

Publication Number Publication Date
CN112506488A true CN112506488A (en) 2021-03-16

Family

ID=74957927

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011275042.8A Pending CN112506488A (en) 2020-11-16 2020-11-16 Method for generating programming language class based on sql creating statement

Country Status (1)

Country Link
CN (1) CN112506488A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113961588A (en) * 2021-10-27 2022-01-21 北京科杰科技有限公司 Big data SQL program design method based on configurable parameters
CN117075911A (en) * 2023-10-13 2023-11-17 北京人大金仓信息技术股份有限公司 Variable code conversion method from PL language to C language, storage medium and apparatus

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113961588A (en) * 2021-10-27 2022-01-21 北京科杰科技有限公司 Big data SQL program design method based on configurable parameters
CN117075911A (en) * 2023-10-13 2023-11-17 北京人大金仓信息技术股份有限公司 Variable code conversion method from PL language to C language, storage medium and apparatus
CN117075911B (en) * 2023-10-13 2024-01-12 北京人大金仓信息技术股份有限公司 Variable code conversion method from PL language to C language, storage medium and apparatus

Similar Documents

Publication Publication Date Title
US6983238B2 (en) Methods and apparatus for globalizing software
US7979793B2 (en) Graphical creation of a document conversion template
CN100511215C (en) Multilingual translation memory and translation method thereof
CN109582647B (en) Unstructured evidence file oriented analysis method and system
US7853936B2 (en) Compilation of nested regular expressions
CN112506488A (en) Method for generating programming language class based on sql creating statement
US20230130267A1 (en) System and Method for Efficient Transliteration of Machine Interpretable Languages
CN105975446A (en) Method and system for displaying word document content by modules in mobile phone terminal
WO2006136055A1 (en) A text data mining method
CN111695002B (en) Database-independent query method based on XML sentences
CN114546988A (en) Method for supporting multi-field type markdown database document to sql table building statement
CN113297251A (en) Multi-source data retrieval method, device, equipment and storage medium
KR100762712B1 (en) Method for transforming of electronic document based on mapping rule and system thereof
CN111831624A (en) Data table creating method and device, computer equipment and storage medium
WO2023007791A1 (en) Program code automatic generation system
CN116303359A (en) Method for realizing multi-type document export of database structure
CN102937910A (en) System and method for cross-platform conversion of control algorithms
WO2010025062A1 (en) Automatic test map generation for system verification test
CN110083822B (en) Conversion method for converting requirement text into SysML requirement diagram
CN113032366A (en) SQL syntax tree analysis method based on Flex and Bison
Falkenstine et al. Natural Language Processing for Autonomous Identification of Impactful Changes to Specification Documents
Zhang et al. A dynamic form rendering method for web multi-front framework
Heiden Annotation-based digital text corpora analysis within the TXM platform
CN116450717B (en) Data integration method and information management system for cross-service modules
WO2024108986A1 (en) Communication network service processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination