CN112351053B - Remote access method, device, equipment and medium for embedded database - Google Patents
Remote access method, device, equipment and medium for embedded database Download PDFInfo
- Publication number
- CN112351053B CN112351053B CN201910727098.3A CN201910727098A CN112351053B CN 112351053 B CN112351053 B CN 112351053B CN 201910727098 A CN201910727098 A CN 201910727098A CN 112351053 B CN112351053 B CN 112351053B
- Authority
- CN
- China
- Prior art keywords
- embedded
- equipment
- request
- client
- function
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 71
- 230000005540 biological transmission Effects 0.000 claims abstract description 49
- 238000004891 communication Methods 0.000 claims abstract description 44
- 238000012545 processing Methods 0.000 claims abstract description 35
- 230000006870 function Effects 0.000 claims description 205
- 238000003780 insertion Methods 0.000 claims description 49
- 230000037431 insertion Effects 0.000 claims description 49
- 238000004590 computer program Methods 0.000 claims description 9
- 230000000694 effects Effects 0.000 abstract description 6
- 238000010586 diagram Methods 0.000 description 6
- 238000004458 analytical method Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 238000012966 insertion method Methods 0.000 description 2
- 238000012856 packing Methods 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 239000002253 acid Substances 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention discloses a remote access method, a remote access device, equipment and a medium for an embedded database. The method comprises the following steps: the embedded equipment runs a server function and starts a transmission control protocol service, the server function developed on the basis of the source code of the embedded database is used for enabling the embedded equipment to establish communication connection with the client equipment by the identity of the server, and the client equipment runs the client function in advance; the embedded equipment receives a connection request of the client equipment and receives an operation request of the client equipment after the connection is successful; and the embedded equipment calls a matched remote operation processing function to analyze the operation request according to the type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database. The scheme realizes the effect of remotely accessing the embedded database stored in the embedded device by the client device, and provides great convenience for the user to access the embedded database.
Description
Technical Field
The embodiment of the invention relates to the field of embedded technology, in particular to a remote access method, a device, equipment and a medium for an embedded database.
Background
SQLite, a lightweight database, is a relational database management system that adheres to ACID (acronyms for four basic elements for correct execution of database transactions, Atomicity-Atomicity, Consistency-Consistency, Isolation-Isolation, Durability-persistence). Its design target is embedded, has been used in many embedded products at present, and moreover, SQLite occupies very little resources, and only a few hundred K of memory may be sufficient in an embedded device. However, the SQLite is only used locally, i.e. only used in the corresponding embedded device, which brings great inconvenience to the user.
Disclosure of Invention
The embodiment of the invention provides a remote access method, a remote access device, equipment and a remote access medium for an embedded database, and provides convenience for users of the embedded database.
In a first aspect, an embodiment of the present invention provides a remote access method for an embedded database, including:
the embedded equipment runs a server function and starts a transmission control protocol service; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment by the identity of a server;
the embedded device receives a connection request sent by client equipment and receives an operation request sent by the client equipment after the embedded device is successfully connected with the client equipment, wherein the client equipment runs a client function in advance, and the client function is matched with the server function and used for enabling the client equipment to establish communication connection with the embedded device; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the embedded equipment calls a matched remote operation processing function to analyze the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeds back the operation result to the client equipment.
In a second aspect, an embodiment of the present invention further provides a remote access method for an embedded database, including:
the client equipment runs a client function and sends a connection request to the embedded equipment; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, the embedded equipment runs a server function in advance and starts a transmission control protocol service, an embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of source codes of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment according to the identity of a server;
after the client device is successfully connected with the embedded device, sending an operation request to the embedded device, so that the embedded device calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the client equipment receives the operation result fed back by the embedded equipment.
In a third aspect, an embodiment of the present invention provides a remote access apparatus for an embedded database, which is applied to an embedded device, and includes:
the service starting module is used for the embedded equipment to run the server function and start the transmission control protocol service; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment in the identity of a server;
the request receiving module is used for receiving a connection request sent by client equipment by the embedded equipment and receiving an operation request sent by the client equipment after the embedded equipment is successfully connected with the client equipment, wherein a client function is operated in advance by the client equipment and is matched with the server function so as to establish communication connection between the client equipment and the embedded equipment; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the request processing and feedback module is used for calling a matched remote operation processing function to analyze the operation request according to the request type of the operation request by the embedded equipment, calling an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeding back an operation result to the client equipment.
In a fourth aspect, an embodiment of the present invention provides a remote access apparatus for an embedded database, which is applied to a client device, and includes:
the service connection module is used for the client equipment to run a client function and send a connection request to the embedded equipment; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, the embedded equipment runs the server function in advance and starts transmission control protocol service, an embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of source codes of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment according to the identity of a server;
the request sending module is used for sending an operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment so that the embedded equipment calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the result receiving module is used for receiving the operation result fed back by the embedded equipment by the client equipment.
In a fifth aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the remote access method applied to the embedded database of the embedded device according to any embodiment of the present invention.
In a sixth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the remote access method applied to an embedded database of an embedded device according to any embodiment of the present invention.
In a seventh aspect, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program that is stored in the memory and is executable on the processor, where when the processor executes the computer program, the method for remotely accessing an embedded database applied to a client device according to any embodiment of the present invention is implemented.
In an eighth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the remote access method applied to the embedded database of the client device according to any embodiment of the present invention.
In the embodiment of the invention, the embedded equipment runs a server function in advance and starts a transmission control protocol service; the client equipment sends a connection request to the embedded equipment after running the client function, and sends a remote operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment; the embedded equipment firstly calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on an embedded database, and feeds back the operation result to the client equipment; the server function and the client function are matched, are both functions developed on the basis of the source code of the embedded database, and are used for establishing remote communication connection between the client equipment and the embedded equipment. Therefore, a client/server structure is established through the transmission control protocol, the effect that the client equipment remotely accesses the embedded database stored in the embedded equipment is achieved, and great convenience is provided for the operation that a user accesses the embedded database.
Drawings
Fig. 1 is a flowchart of a remote access method for an embedded database according to a first embodiment of the present invention;
fig. 2 is a flowchart of a remote access method for an embedded database according to a second embodiment of the present invention;
fig. 3 is a flowchart of a remote access method for an embedded database according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a remote access apparatus for an embedded database according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a remote access device for an embedded database according to a fifth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device in the sixth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some structures related to the present invention are shown in the drawings, not all of them.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1 is a flowchart of a remote access method for an embedded database according to an embodiment of the present invention, where this embodiment is applicable to a case of performing remote access to an embedded database, and the method may be executed by a remote access apparatus applied to an embedded database of an embedded device according to an embodiment of the present invention, where the apparatus may be implemented in a software and/or hardware manner, and may be generally integrated in a processor of the embedded device.
As shown in fig. 1, the method of this embodiment specifically includes:
s110, the embedded equipment runs a server function and starts a transmission control protocol service; the embedded database is stored in the embedded device, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded device to establish communication connection with the client device by the identity of the server.
The embedded database is stored in the embedded device, and a user can directly access the embedded database locally on the embedded device, and typically, the embedded database may be an open-source database SQLite 3. The design goal of SQLite3 is embedded, very low resource usage, and very wide usage.
The server function is a function developed on the basis of SQLite3 source codes. After the embedded device system is normally started, after a server function is operated and a TCP (Transmission Control Protocol) service is started, a communication connection of a client device is waited, and the client device may be any one of networked computer devices. After the embedded device runs the server function, the embedded device is equivalent to a server device.
S120, the embedded device receives a connection request sent by the client device, and receives an operation request sent by the client device after the embedded device is successfully connected with the client device; the client function is matched with the server function and used for enabling the client device to be in communication connection with the embedded device.
Specifically, the operation request includes a request type and an embedded database statement corresponding to the request type.
After the system is normally started, if the client device determines that the embedded device is operated, the client device can operate the client function and then perform communication connection with the embedded device. The client function is also a function developed on the basis of the SQLite3 source code, and is correspondingly matched with the server function.
The client device sends a connection request to the embedded device, and the embedded device establishes communication connection with the client device after receiving the connection request. When the embedded device is successfully connected with the Client device, a C (Client)/S (Server) structure is successfully built through a TCP (transmission control protocol), so that remote operation on the embedded database can be realized after one or more clients are in communication connection with the Server (embedded device), and the standard network protocol of TCP can include data integrity of remote communication.
After the communication connection between the client device and the embedded device is successfully established, an operation request can be remotely sent to the embedded device, wherein the operation request not only comprises a request type, but also comprises an embedded database statement corresponding to the request type, and the embedded database statement is matched with the embedded database source code and is also applicable to the local embedded device. The operation request can be sent to the embedded device in the form of a communication data packet, a packing protocol of the data packet is preset, and the embedded device can analyze and process the data packet according to the packing rule after receiving the operation request.
Specifically, the operation request may include one or more of a create request, an insert request, a query request, a delete request, and an update request. The insertion request can be a normal insertion request and a transaction insertion request, and the difference between the normal insertion request and the transaction insertion request is as follows: when the embedded equipment receives a conventional insertion request, the embedded equipment executes an insertion operation on the embedded database once receiving one piece of data; when the embedded device receives the transaction insertion request, the embedded device receives all the data and then uniformly executes one insertion operation on the embedded database.
S130, the embedded device calls a matched remote operation processing function to analyze the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeds back the operation result to the client device.
And the remote operation processing function is corresponding to the operation request type and is used for analyzing the operation request to obtain the embedded database statement corresponding to the request type in the operation request.
The embedded database source code function refers to an open source function of the embedded database, and specifically may be a bottom interface of the embedded database, configured to execute an embedded database statement corresponding to the request type.
After receiving the operation request, the embedded device firstly determines the request type of the operation request, then calls a remote operation processing function corresponding to the request type to analyze other contents in the operation request to obtain an embedded database statement corresponding to the request type, and then calls an embedded database source code function to execute the operation corresponding to the embedded database statement on the embedded database.
For example, the operation type of the request type is a query request, the embedded device calls a remote query function to analyze the operation request to obtain an embedded database statement corresponding to the query request, then calls an embedded database source code function to execute the embedded database statement corresponding to the query request on the embedded database, and feeds back a query result to the client device after the query is finished.
In the embodiment of the invention, embedded equipment runs a server function in advance and starts a transmission control protocol service; the client equipment sends a connection request to the embedded equipment after running the client function, and sends a remote operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment; the embedded equipment firstly calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on an embedded database, and feeds back the operation result to the client equipment; the server function and the client function are matched, are both functions developed on the basis of the source code of the embedded database, and are used for establishing remote communication connection between the client equipment and the embedded equipment. Therefore, a client/server structure is established through the transmission control protocol, the effect that the client equipment remotely accesses the embedded database stored in the embedded equipment is achieved, and great convenience is provided for the operation that a user accesses the embedded database.
As a specific implementation manner of this embodiment, the operation request sent by the client device is a transaction insertion request, and correspondingly, the embedded device may invoke a matched remote operation processing function to perform analysis processing on the operation request according to a request type of the operation request, and then invoke an embedded database source code function to perform an operation matched with the operation request on the embedded database, which specifically is:
if the embedded device root determines that the operation request is a transaction insertion request, calling a remote transaction insertion function, and sending a data transmission instruction to the client device, wherein the data transmission instruction is used for instructing the client device to transmit batch data until all data is transmitted;
and after receiving all the data transmitted by the client equipment, the embedded equipment calls a source code function of the embedded database to execute the operation of inserting all the data into the embedded database.
After the client device and the embedded device successfully establish remote communication connection, the client device sends a remote transaction insertion request to the embedded device, the embedded device sends a data transmission instruction to the client device after receiving the remote transaction insertion request, the client device sends data needing transaction insertion to the embedded device in batches after receiving the data transmission instruction until the data is sent, and after receiving all the transmitted data, the embedded device calls an embedded database source code function (namely a bottom layer function) to execute the operation of inserting all the data into the embedded database and feeds back the transaction insertion result to the client device.
In the technical scheme, the embedded device encapsulates the bottom-layer transaction insertion method provided by the embedded database, so that the effective operation of transaction insertion through remote operation is realized, and the performance of the remote insertion operation is greatly improved.
Example two
Fig. 2 is a flowchart of a remote access method for an embedded database according to a second embodiment of the present invention. The present embodiment is optimized based on the above embodiments. The operation request is specifically an insertion request, and a file storage system of the embedded device is specifically in a FAT format; in a corresponding manner, the first and second optical fibers are,
the method for executing the operation matched with the operation request on the embedded database by calling the source code function of the embedded database specifically comprises the following steps:
in the process of calling the source code function of the embedded database to execute the inserting operation matched with the inserting request on the embedded database, if the storage error reporting information is received, a new embedded database sub-database matched with the original embedded database is created; the name of the new embedded database is matched with the name of the original embedded database;
and calling the source code function of the embedded database to continue to execute the unfinished inserting operation matched with the inserting request on the new embedded database.
As shown in fig. 2, the method of this embodiment specifically includes:
s210, the embedded equipment runs a server function and starts a transmission control protocol service; the embedded database is stored in the embedded device, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded device to establish communication connection with the client device by the identity of the server.
S220, the client equipment runs a client function and sends a connection request to the embedded equipment; the client function is matched with the server function and used for enabling the client device to be in communication connection with the embedded device.
And S230, the embedded device receives the connection request sent by the client device and feeds back the connection result to the client device.
S240, after the client device is determined to be successfully connected with the embedded device, an insertion request is sent to the embedded device.
And S250, after the embedded equipment receives the insertion request, calling a remote insertion function to analyze the operation request to obtain an embedded database statement corresponding to the insertion request.
And S260, the embedded equipment calls an embedded database source code function to execute an inserting operation corresponding to the embedded database statement on the embedded database.
And S270, the embedded device detects whether the storage error reporting information is received in real time in the process of executing the insertion operation, if so, the step S280 is executed, and if not, the step S260 is continuously executed.
In this embodiment, the file storage system of the embedded device is specifically in the FAT format, but the file storage system in the FAT format has a certain limitation on the size of a single file, for example, FAT16 limits that the size of a single file does not exceed 2G, and FAT32 limits that the size of a single file does not exceed 4G. The capacity of the embedded database is also limited due to file size limitations of the file system FAT format.
Taking the file storage system of the embedded device as FAT16 as an example, when the size of the embedded database is close to 2G, if the embedded database is inserted again, the embedded internal mechanism finds that the data cannot be inserted any more, and returns storage Error reporting information such as "database full" or "IO Error".
And in the process of executing the inserting operation by the embedded equipment, if the stored error reporting information is not detected, continuously executing the corresponding inserting operation.
And S280, creating a new embedded database sublibrary matched with the original embedded database.
In the process of executing the inserting operation by the embedded equipment, if the error information of the storage is detected, the operation of creating a new embedded data sub-database is triggered.
The type of the new embedded database sublibrary triggered to be created is completely the same as that of the original embedded database with limited capacity, and the name of the new embedded database sublibrary is matched with that of the original embedded database.
The naming rule of the new embedded database sub-database can be preset according to the use habit of the user. In order to better identify that the new embedded database sub-database is a new database corresponding to the original embedded database with limited capacity, the naming rule may be specifically set to "the name of the new embedded database sub-database is different from the suffix of the name of the original embedded database, and the suffix is a sequential number or a creation date, etc.", for example, the name of the original embedded database with limited capacity is XX _1, and the name of the new embedded database sub-database may be XX _ 2.
And S290, calling the source code function of the embedded database to continue to perform unfinished inserting operation matched with the inserting request on the new embedded database.
After the new embedded database sub-library is created, the last unfinished inserting operation can be continued until the inserting operation is finished.
For the sake of brevity, the present embodiment is not explained in detail herein, and reference is made to the aforementioned embodiments for further description.
The technical scheme breaks through the maximum capacity limit of the embedded database file on the FAT format file system, adopts a new database full creation mechanism, realizes remote database capacity expansion, ensures the validity and the integrity of data storage, and avoids the problem that the user experience is influenced due to the data loss caused by the full report of a single database.
EXAMPLE III
Fig. 3 is a flowchart of a remote access method for an embedded database according to a third embodiment of the present invention, where this embodiment is applicable to a case of performing remote access to an embedded database, and the method may be executed by a remote access apparatus for an embedded database of a client device according to the third embodiment of the present invention, where the apparatus may be implemented in a software and/or hardware manner, and may be generally integrated in a processor of the client device.
As shown in fig. 3, the method of this embodiment specifically includes:
s310, the client equipment runs a client function and sends a connection request to the embedded equipment; the embedded device runs a server function in advance and starts a transmission control protocol service, the embedded database is stored in the embedded device, and the server function is a function developed on the basis of source codes of the embedded database, is matched with the client function and is used for enabling the embedded device to establish communication connection with the client device according to the identity of the server.
Typically, the embedded database may be SQLite 3.
S320, after the client device is successfully connected with the embedded device, sending an operation request to the embedded device, so that the embedded device calls a matched remote operation processing function to analyze the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database.
The operation request comprises a request type and an embedded database statement corresponding to the request type.
Specifically, the operation request may include one or more of a create request, an insert request, a query request, a delete request, and an update request. Wherein the insert request can be a regular insert request and a transaction insert request.
S330, the client device receives the operation result fed back by the embedded device.
For the sake of brevity, the present embodiment is not explained in detail herein, and reference is made to the aforementioned embodiments for further description.
In the embodiment of the invention, the embedded equipment runs a server function in advance and starts a transmission control protocol service; the client equipment sends a connection request to the embedded equipment after running the client function, and sends a remote operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment; the embedded equipment firstly calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on an embedded database, and feeds back the operation result to the client equipment; the server function and the client function are matched, are both functions developed on the basis of the source code of the embedded database, and are used for establishing remote communication connection between the client equipment and the embedded equipment. Therefore, a client/server structure is established through the transmission control protocol, the effect that the client equipment remotely accesses the embedded database stored in the embedded equipment is achieved, and great convenience is provided for the operation that a user accesses the embedded database.
As a specific implementation manner of this embodiment, the operation request sent by the client device is a transaction insertion request, and correspondingly, S320 may specifically be:
the method comprises the steps that a client device sends a transaction insertion request to an embedded device, so that the embedded device calls a remote transaction insertion function and sends a data transmission instruction to the client device, wherein the data transmission instruction is used for instructing the client device to transmit batch data until all data are transmitted;
after the client device receives the data transmission instruction, the data corresponding to the transaction insertion request are transmitted in batches until all the data are transmitted, so that the embedded device calls the source code function of the embedded database to execute the operation of inserting all the data into the embedded database after receiving all the data transmitted by the client device.
After the client device and the embedded device successfully establish remote communication connection, the client device sends a remote transaction insertion request to the embedded device, the embedded device sends a data transmission instruction to the client device after receiving the remote transaction insertion request, the client device sends data needing transaction insertion to the embedded device in batches after receiving the data transmission instruction until the data is sent, and after receiving all the transmitted data, the embedded device calls an embedded database source code function (namely a bottom layer function) to execute the operation of inserting all the data into the embedded database and feeds back the transaction insertion result to the client device.
In the technical scheme, the embedded device encapsulates the bottom-layer transaction insertion method provided by the embedded database, so that the effective operation of transaction insertion through remote operation is realized, and the performance of the remote insertion operation is greatly improved.
Example four
Fig. 4 is a schematic structural diagram of a remote access apparatus for an embedded database according to a fourth embodiment of the present invention, where the apparatus may be implemented in software and/or hardware, and may be generally integrated in a processor of an embedded device. As shown in fig. 4, the remote access apparatus for an embedded database is applied to an embedded device, and specifically includes: a service initiation module 410, a request receiving module 420 and a request processing and feedback module 430. Wherein,
a service starting module 410, configured to run a server function and start a tcp service for the embedded device; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment by the identity of a server;
a request receiving module 420, configured to receive, by the embedded device, a connection request sent by a client device, and receive, after the connection is successful with the client device, an operation request sent by the client device, where the client device runs a client function in advance, and the client function is matched with the server function and is used to establish a communication connection between the client device and the embedded device; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the request processing and feedback module 430 is configured to, after the embedded device calls the matched remote operation processing function to analyze the operation request according to the request type of the operation request, call an embedded database source code function to execute an operation matched with the operation request on the embedded database, and feed back an operation result to the client device.
In the embodiment of the invention, embedded equipment runs a server function in advance and starts a transmission control protocol service; the client equipment sends a connection request to the embedded equipment after running the client function, and sends a remote operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment; the embedded equipment firstly calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on an embedded database, and feeds back the operation result to the client equipment; the server function and the client function are matched, are both functions developed on the basis of the source code of the embedded database, and are used for establishing remote communication connection between the client equipment and the embedded equipment. Therefore, a client/server structure is established through the transmission control protocol, the effect that the client equipment remotely accesses the embedded database stored in the embedded equipment is achieved, and great convenience is provided for the operation that a user accesses the embedded database.
Specifically, the operation request includes at least one of the following items: creating requests, inserting requests, inquiring requests, deleting requests and updating requests; wherein the insert request comprises a regular insert request and a transaction insert request.
Specifically, the embedded database includes SQLite 3.
As a specific implementation manner of this embodiment, the operation request is a transaction insertion request, and correspondingly, the request processing and feedback module 430 is specifically configured to, if the embedded device root determines that the operation request is a transaction insertion request, invoke a remote transaction insertion function, and send a data transmission instruction to the client device, where the data transmission instruction is used to instruct the client device to perform bulk data transmission until all data is completely transmitted; and after the embedded equipment receives all the data transmitted by the client equipment, calling an embedded database source code function to execute the operation of inserting all the data into the embedded database.
As another specific implementation manner of this embodiment, the operation request is an insertion request, and correspondingly, the request processing and feedback module 430 is further specifically configured to, in a process of invoking an embedded database source code function to perform an insertion operation matching the insertion request on the embedded database, if storage error reporting information is received, create a new embedded database sub-library matching the original embedded database; the names of the new embedded database sub-databases are matched with the names of the original embedded databases; and calling an embedded database source code function to continue to execute the unfinished inserting operation matched with the inserting request on the new embedded database.
The remote access device of the embedded database can execute the remote access method applied to the embedded database of the embedded equipment provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a remote access apparatus for an embedded database according to a fifth embodiment of the present invention, where the apparatus may be implemented in software and/or hardware, and may be generally integrated in a processor of a client device. As shown in fig. 5, the remote access apparatus for an embedded database is applied to a client device, and specifically includes: a service connection module 510, a request transmission module 520, and a result reception module 530. Wherein,
a service connection module 510, configured to enable a client device to run a client function and send a connection request to the embedded device; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, the embedded equipment runs the server function in advance and starts transmission control protocol service, an embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of source codes of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment in the identity of a server;
a request sending module 520, configured to send an operation request to the embedded device after the client device is successfully connected to the embedded device, so that the embedded device invokes a matched remote operation processing function to perform analysis processing on the operation request according to a request type of the operation request, and then invokes an embedded database source code function to perform an operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
a result receiving module 530, configured to receive, by the client device, an operation result fed back by the embedded device.
In the embodiment of the invention, embedded equipment runs a server function in advance and starts a transmission control protocol service; the client equipment sends a connection request to the embedded equipment after running the client function, and sends a remote operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment; the embedded equipment firstly calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on an embedded database, and feeds back the operation result to the client equipment; the server function and the client function are matched, are both functions developed on the basis of the source code of the embedded database, and are used for establishing remote communication connection between the client equipment and the embedded equipment. Therefore, a client/server structure is established through the transmission control protocol, the effect that the client equipment remotely accesses the embedded database stored in the embedded equipment is achieved, and great convenience is provided for the operation that a user accesses the embedded database.
Specifically, the operation request includes at least one of the following items: creating requests, inserting requests, inquiring requests, deleting requests and updating requests; wherein the insert request comprises a regular insert request and a transaction insert request.
Specifically, the embedded database includes SQLite 3.
As a specific implementation manner of this embodiment, the operation request is a transaction insertion request; correspondingly, the request sending module 520 is specifically configured to send, by the client device, a transaction insertion request to the embedded device, so that the embedded device invokes a remote transaction insertion function and sends a data transmission instruction to the client device, where the data transmission instruction is used to instruct the client device to perform bulk data transmission until all data is completely transmitted; and after receiving the data transmission instruction, the client device transmits the data corresponding to the transaction insertion request in batch until all data are transmitted, so that the embedded device calls an embedded database source code function to execute the operation of inserting all data into the embedded database after receiving all data transmitted by the client device.
The remote access device of the embedded database can execute the remote access method applied to the embedded database of the client device provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example six
Fig. 6 is a schematic structural diagram of a computer device according to a sixth embodiment of the present invention, as shown in fig. 6, the computer device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of processors 610 in the computer device may be one or more, and one processor 610 is taken as an example in fig. 6; the processor 610, the memory 620, the input device 630 and the output device 640 in the computer apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 6.
The memory 620 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to a remote access method applied to an embedded database of an embedded device in the embodiments of the present invention (for example, the service initiation module 410, the request receiving module 420, and the request processing and feedback module 430 in a remote access apparatus applied to an embedded database of an embedded device), and program instructions/modules corresponding to a remote access method applied to an embedded database of a client device in the embodiments of the present invention (for example, the service connection module 510, the request sending module 520, and the result receiving module 530 in a remote access apparatus applied to an embedded database of a client device). The processor 610 executes various functional applications and data processing of the computer device by executing software programs, instructions, and modules stored in the memory 620, i.e., implementing the above-described remote access method applied to the embedded database of the embedded device or the remote access method applied to the embedded database of the client device.
The memory 620 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 620 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 620 may further include memory located remotely from the processor 610, which may be connected to a computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 630 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus. The output device 640 may include a display device such as a display screen.
EXAMPLE seven
An embodiment of the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method for remote access to an embedded database, including:
the embedded equipment runs a server function and starts a transmission control protocol service; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment by the identity of a server;
the embedded device receives a connection request sent by client equipment and receives an operation request sent by the client equipment after the embedded device is successfully connected with the client equipment, wherein the client equipment runs a client function in advance, and the client function is matched with the server function and used for enabling the client equipment to establish communication connection with the embedded device; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the embedded equipment calls a matched remote operation processing function to analyze the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeds back the operation result to the client equipment.
Alternatively, the computer executable instructions, when executed by a computer processor, are for performing a method of remote access of an embedded database, comprising:
the client equipment runs a client function and sends a connection request to the embedded equipment; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, the embedded equipment runs a server function in advance and starts transmission control protocol service, an embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of source codes of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment in the identity of the server;
after the client device is successfully connected with the embedded device, sending an operation request to the embedded device, so that the embedded device calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the client equipment receives the operation result fed back by the embedded equipment.
Optionally, the computer-executable instructions, when executed by the computer processor, may be further used to implement a technical solution of the remote access method applied to an embedded database of an embedded device or a client device according to any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on this understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for causing a computer device to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the remote access apparatus for an embedded database, the units and modules included in the embodiment are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A remote access method for an embedded database, comprising:
the embedded equipment runs a server function and starts a transmission control protocol service; after the embedded equipment runs a server function, the embedded equipment is equivalent to server equipment; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment by the identity of a server;
the embedded device receives a connection request sent by client equipment and receives an operation request sent by the client equipment after the embedded device is successfully connected with the client equipment, wherein the client equipment runs a client function in advance, and the client function is matched with the server function and used for enabling the client equipment to establish communication connection with the embedded device; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the embedded equipment calls a matched remote operation processing function to analyze the operation request according to the request type of the operation request, then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeds back the operation result to the client equipment.
2. The method of claim 1, wherein the operation request is a transaction insert request;
the embedded device calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, wherein the operation comprises the following steps:
if the embedded device determines that the operation request is a transaction insertion request, calling a remote transaction insertion function, and sending a data transmission instruction to the client device, wherein the data transmission instruction is used for instructing the client device to transmit batch data until all data is transmitted;
and after the embedded equipment receives all the data transmitted by the client equipment, calling an embedded database source code function to execute the operation of inserting all the data into the embedded database.
3. The method according to claim 1, wherein the operation request is an insert request, and the file storage system of the embedded device is in FAT format;
calling an embedded database source code function to execute the operation matched with the operation request on the embedded database, wherein the operation comprises the following steps:
in the process of calling an embedded database source code function to execute an inserting operation matched with the inserting request on the embedded database, if storage error information is received, a new embedded database sub-library matched with the original embedded database is created; the name of the new embedded database is matched with the name of the original embedded database;
and calling an embedded database source code function to continue to execute the unfinished inserting operation matched with the inserting request on the new embedded database.
4. A remote access method for an embedded database, comprising:
the client equipment runs a client function and sends a connection request to the embedded equipment; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, and the embedded equipment runs a server function in advance and starts transmission control protocol service; after the embedded equipment runs a server function, the embedded equipment is equivalent to server equipment; the embedded database is stored in the embedded equipment, the server function is a function developed on the basis of the source code of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment by the identity of the server;
after the client device is successfully connected with the embedded device, sending an operation request to the embedded device, so that the embedded device calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the client equipment receives the operation result fed back by the embedded equipment.
5. The method of claim 4, wherein the operation request is a transaction insert request;
the client device sends an operation request to the embedded device, so that the embedded device calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request, and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database, wherein the operation request comprises the following steps:
the client device sends a transaction insertion request to the embedded device so that the embedded device calls a remote transaction insertion function and sends a data transmission instruction to the client device, wherein the data transmission instruction is used for instructing the client device to transmit batch data until all data are transmitted;
and after receiving the data transmission instruction, the client device transmits the data corresponding to the transaction insertion request in batch until all data are transmitted, so that the embedded device calls an embedded database source code function to execute the operation of inserting all data into the embedded database after receiving all data transmitted by the client device.
6. The method of any of claims 1-5, wherein the embedded database comprises SQLite 3.
7. A remote access device of an embedded database is applied to an embedded device, and is characterized by comprising:
the service starting module is used for the embedded equipment to run the server function and start the transmission control protocol service; after the embedded equipment runs a server function, the embedded equipment is equivalent to server equipment; the embedded database is stored in the embedded equipment, and the server function is a function developed on the basis of the source code of the embedded database and is used for enabling the embedded equipment to establish communication connection with client equipment by the identity of a server;
the request receiving module is used for receiving a connection request sent by client equipment by the embedded equipment and receiving an operation request sent by the client equipment after the embedded equipment is successfully connected with the client equipment, wherein a client function is operated in advance by the client equipment and is matched with the server function so as to establish communication connection between the client equipment and the embedded equipment; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the request processing and feedback module is used for calling a matched remote operation processing function to analyze the operation request according to the request type of the operation request by the embedded equipment, calling an embedded database source code function to execute the operation matched with the operation request on the embedded database, and feeding back an operation result to the client equipment.
8. A remote access device of an embedded database, which is applied to a client device, is characterized by comprising:
the service connection module is used for the client equipment to run the client function and send a connection request to the embedded equipment; the client function is used for enabling the client equipment to establish communication connection with the embedded equipment, and the embedded equipment runs a server function in advance and starts transmission control protocol service; after the embedded equipment runs a server function, the embedded equipment is equivalent to server equipment; the embedded database is stored in the embedded equipment, the server function is a function developed on the basis of the source code of the embedded database, is matched with the client function and is used for enabling the embedded equipment to establish communication connection with the client equipment in the identity of the server;
the request sending module is used for sending an operation request to the embedded equipment after the client equipment is successfully connected with the embedded equipment so that the embedded equipment calls a matched remote operation processing function to analyze and process the operation request according to the request type of the operation request and then calls an embedded database source code function to execute the operation matched with the operation request on the embedded database; the operation request comprises a request type and an embedded database statement corresponding to the request type;
and the result receiving module is used for receiving the operation result fed back by the embedded equipment by the client equipment.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-3, 6, or 4-6.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-3, 6 or 4-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910727098.3A CN112351053B (en) | 2019-08-07 | 2019-08-07 | Remote access method, device, equipment and medium for embedded database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910727098.3A CN112351053B (en) | 2019-08-07 | 2019-08-07 | Remote access method, device, equipment and medium for embedded database |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112351053A CN112351053A (en) | 2021-02-09 |
CN112351053B true CN112351053B (en) | 2022-09-20 |
Family
ID=74367293
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910727098.3A Active CN112351053B (en) | 2019-08-07 | 2019-08-07 | Remote access method, device, equipment and medium for embedded database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112351053B (en) |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102253890A (en) * | 2011-08-16 | 2011-11-23 | 北京汉邦高科数字技术有限公司 | Embedded debugging method |
US20160196131A1 (en) * | 2014-07-07 | 2016-07-07 | Symphony Teleca Corporation | Remote Embedded Device Update Platform Apparatuses, Methods and Systems |
CN104598176A (en) * | 2014-12-24 | 2015-05-06 | 合肥协知行信息系统工程有限公司 | Embedded wireless print terminal |
CN109462659B (en) * | 2018-12-17 | 2021-06-15 | 深圳市网心科技有限公司 | Remote access control system, method and storage medium for embedded device |
-
2019
- 2019-08-07 CN CN201910727098.3A patent/CN112351053B/en active Active
Non-Patent Citations (1)
Title |
---|
低端嵌入式设备Web服务器的研究与实现;高珀珀 等;《计算机工程(2005年第10期)》;20050520;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN112351053A (en) | 2021-02-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111277639B (en) | Method and device for maintaining data consistency | |
CN113259359B (en) | Edge node capability supplementing method, system, medium and electronic terminal | |
CN111258723B (en) | Transaction processing method, device, system, medium and equipment of distributed system | |
CN112751847A (en) | Interface call request processing method and device, electronic equipment and storage medium | |
CN109343983B (en) | Information interaction method, device, equipment and storage medium between function modules | |
CN114090388A (en) | Information acquisition method, server cluster, server and equipment | |
CN111259022A (en) | Information synchronization method, synchronization system, computer equipment and medium | |
CN105373563B (en) | Database switching method and device | |
CN114327799B (en) | Distributed transaction processing method and device, electronic equipment and storage medium | |
WO2022121492A1 (en) | File transmission method and apparatus, computer device, and storage medium | |
CN110933188A (en) | Remote service calling method, system, server and storage medium | |
CN112351053B (en) | Remote access method, device, equipment and medium for embedded database | |
CN106550021B (en) | Push method and device for push message | |
CN111881086A (en) | Big data storage method, big data query method, electronic device and storage medium | |
CN108829735B (en) | Synchronization method, device, server and storage medium for parallel execution plan | |
CN111782417A (en) | Message-based multi-process sharing serial port resource implementation method | |
CN114090268B (en) | Container management method and container management system | |
CN113553206B (en) | Data event execution method and device, electronic equipment and computer readable medium | |
CN115629909A (en) | Service data processing method and device, electronic equipment and storage medium | |
CN114328530A (en) | Data isolation method, server and system | |
CN112714181A (en) | Data transmission method and device | |
CN112131263A (en) | Software package obtaining method, system, device, electronic equipment and storage medium | |
CN108491448B (en) | Data pushing method and device | |
CN108288135B (en) | System compatibility method and device, computer readable storage medium and electronic equipment | |
CN112732728A (en) | Data synchronization method and system |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |