CN109299182A - The management method and device of the session connection of database - Google Patents
The management method and device of the session connection of database Download PDFInfo
- Publication number
- CN109299182A CN109299182A CN201811345183.5A CN201811345183A CN109299182A CN 109299182 A CN109299182 A CN 109299182A CN 201811345183 A CN201811345183 A CN 201811345183A CN 109299182 A CN109299182 A CN 109299182A
- Authority
- CN
- China
- Prior art keywords
- session connection
- connection
- session
- database
- unavailable
- 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
Links
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a kind of management method of the session connection of database and devices.The described method includes: obtaining the life state information of the session connection of database;According to the life state information of the session connection, the availability of the session connection is detected;When detecting that the session connection is unavailable, not available session connection is handled.
Description
Technical field
The present invention relates to field of information processing, the espespecially a kind of management method and device of the session connection of database.
Background technique
MySQL is a kind of Relational DBMS of open source code, uses most common data base administration language
Speech -- structured query language (Structured Query Language, SQL) carries out data base administration.Using Python
When operating bottom Mysql database, typically established and bottom data based on the session mechanism that sqlalchemy is provided
The connection connection in library, then increase, deletion, modification and inquiry of database etc. operate.But it needs to develop
Personnel oneself safeguard the acquisition of session, use and close, if will lead to number without correctly closing session session connection
The problem of abnormal according to library connection pool, and the connection in database connection pool will appear Joint failure.
Summary of the invention
In order to solve the above-mentioned technical problems, the present invention provides a kind of management method of the session connection of database and dresses
It sets, is capable of the stability of session connection.
In order to reach the object of the invention, the present invention provides a kind of management methods of the session connection of database, comprising:
Obtain the life state information of the session connection of database;
According to the life state information of the session connection, the availability of the session connection is detected;
When detecting that the session connection is unavailable, not available session connection is handled.
In one exemplary embodiment, the life state information according to the session connection, detects the session
The availability of connection, comprising:
The target session that life state is use state is obtained to connect;
The availability of target session connection is detected, testing result is obtained.
In one exemplary embodiment, the life state information according to the session connection, detects the session
The availability of connection, comprising:
Detect whether the session connection terminates;
If the session connection is not finished, judge the session connection whether can normal transmission data, obtain first
Judging result;If first judging result is to be unable to normal transmission data, it is determined that the session connection is unavailable;
If the session connection terminates, judge whether the session connection disconnects the connection with the database, obtains
To the second judging result;If second judging result is the connection not disconnected with the database, it is determined that the session
It connects unavailable.
It is in one exemplary embodiment, described that not available session connection is handled, comprising:
Obtain the connection configuration information of the not available session connection;
According to the connection configuration information, the not available session connection is rebuild.
In one exemplary embodiment, described according to the connection configuration information, to the not available session connection
After being rebuild, the method also includes:
Whether session connection is working properly after detection executes reconstruction operation;
If detecting still unavailable to session connection after the reconstruction operation, the not available session connection is exported
Warning information.
In order to reach the object of the invention, the present invention provides a kind of managing devices of the session connection of database, comprising:
Obtain module, the life state information of the session connection for obtaining database;
Detection module detects the availability of the session connection for the life state information according to the session connection;
Processing module, for handling not available session connection when detecting that the session connection is unavailable.
In one exemplary embodiment, the acquisition module includes:
First acquisition unit is connected for obtaining the target session that life state is use state;
Detection unit, the availability for connecting to the target session detect, and obtain testing result.
In one exemplary embodiment, the detection module includes:
First detection unit, for detecting whether the session connection terminates;
First processing units judge whether the session connection can be normal if be not finished for the session connection
Data are transmitted, the first judging result is obtained, if first judging result is to be unable to normal transmission data, it is determined that the meeting
Words connection is unavailable;Alternatively, judging whether the session connection disconnects and the database if the session connection terminates
Connection, the second judging result is obtained, if second judging result is the connection not disconnected with the database, it is determined that
The session connection is unavailable.
In one exemplary embodiment, the processing module includes:
Second acquisition unit, for obtaining the connection configuration information of the not available session connection;
Reconstruction unit, for being rebuild to the not available session connection according to the connection configuration information.
In one exemplary embodiment, the processing module further include:
Second detection unit, for after rebuilding to the not available session connection, detection to be executed to rebuild and be grasped
Whether session connection is working properly after work;
Output unit, if still unavailable to session connection after the reconstruction operation for detecting, output is described not
The warning information of available session connection.
Embodiment provided by the invention obtains the life state information of the session connection of database, and according to the session
The life state information of connection, detects the availability of the session connection, when detecting that the session connection is unavailable, to not
Available session connection is handled, and is realized to the maintenance of the availability of session connection, is improved the stability of session connection.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by specification, right
Specifically noted structure is achieved and obtained in claim and attached drawing.
Detailed description of the invention
Attached drawing is used to provide to further understand technical solution of the present invention, and constitutes part of specification, with this
The embodiment of application technical solution for explaining the present invention together, does not constitute the limitation to technical solution of the present invention.
Fig. 1 is the flow chart of the management method of the session connection of database provided by the invention;
Fig. 2 is the structure chart of the managing device of the session connection of database provided by the invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with attached drawing to the present invention
Embodiment be described in detail.It should be noted that in the absence of conflict, in the embodiment and embodiment in the application
Feature can mutual any combination.
Step shown in the flowchart of the accompanying drawings can be in a computer system such as a set of computer executable instructions
It executes.Also, although logical order is shown in flow charts, and it in some cases, can be to be different from herein suitable
Sequence executes shown or described step.
Fig. 1 is the flow chart of the management method of the session connection of database provided by the invention.Method shown in Fig. 1 includes:
Step 101, obtain database session connection life state information;
In this step, it can be pre-configured with script file, which is used to obtain the life state of session connection
Information can periodically obtain the life state information, alternatively, according to pre-set time interval;Acquired session
Connection can be whole, be also possible to part, and the connection of part, which can be, by user to be applied using;
Step 102, the life state information according to the session connection, detect the availability of the session connection;
The life state information of session connection can be to obtain, use and terminate;It is currently located according to the session connection
Whether life state, detection session connection can be used under the life state;
Step 103, when detecting that the session connection is unavailable, not available session connection is handled.
By handling the not available session connection, can be terminates the session connection, alternatively, announcement can be issued
Alert, prompting handles the session connection.
Embodiment provided by the invention obtains the life state information of the session connection of database, and according to the session
The life state information of connection, detects the availability of the session connection, when detecting that the session connection is unavailable, to not
Available session connection is handled, and is realized to the maintenance of the availability of session connection, is improved the stability of session connection.
Method provided by the invention is illustrated below:
In one exemplary embodiment, the life state information according to the session connection, detects the session
The availability of connection, comprising:
The target session that life state is use state is obtained to connect;
The availability of target session connection is detected, testing result is obtained.
In the present example embodiment, the life state of session connection can be to obtain, use and terminate;By only to life
Life state is that the target session of use state connects, and the acquisition connected to partial session may be implemented, reduce the quantity of acquisition,
The processing time can be effectively reduced.
In one exemplary embodiment, the life state information according to the session connection, detects the session
The availability of connection, comprising:
Detect whether the session connection terminates;
If the session connection is not finished, judge the session connection whether can normal transmission data, obtain first
Judging result;If first judging result is to be unable to normal transmission data, it is determined that the session connection is unavailable;
If the session connection terminates, judge whether the session connection disconnects the connection with the database, obtains
To the second judging result;If second judging result is the connection not disconnected with the database, it is determined that the session
It connects unavailable.
In the present example embodiment, the time of the availability detection of session connection is a period, therefore needs basis
Whether the session connection terminates the judgement distinguished, and when the session connection is not finished, which is accounted for by user
With, need to judge the session connection to data transmit it is whether normal, if whether data transmission delay is more than preset duration threshold value
Deng;If the session connection terminates, then it represents that the session connection has been released by a user, then whether needs to detect the session connection
The connection of user is disconnected.
It is in one exemplary embodiment, described that not available session connection is handled, comprising:
Obtain the connection configuration information of the not available session connection;
According to the connection configuration information, the not available session connection is rebuild.
In the present example embodiment, it by obtaining the connection configuration information of not available session connection, is rebuild to obtain
Configuration information needed for session connection completes the reconstruction of session connection according to the configuration information.
In one exemplary embodiment, described according to the connection configuration information, to the not available session connection
After being rebuild, the method also includes:
Whether session connection is working properly after detection executes reconstruction operation;
If detecting still unavailable to session connection after the reconstruction operation, the not available session connection is exported
Warning information.
In the present example embodiment, by detecting whether the session connection can be used, to determine the need for alerting, so as to
The session connection is handled in time.
Method provided by the invention is illustrated with application example provided by the invention below:
In order to solve problem above, this case proposes a kind of device that processing Mysql Session is realized based on Python, comes
The management for completing entire session life cycle, by interpreter in Python, research staff only needs using session
Method on increase and explain i.e. according to can.Development efficiency is not only increased by this case, enhance the readability of code and can be safeguarded
Property, and the stability of product is improved, improve competitiveness of the cloud platform in similar product.
The invention proposes a kind of methods for realizing processing Mysql Session based on Python, including database connection
Pond building, session life cycle management and the encapsulation of database universal method;Wherein, Data Connection Pool building can be to pass through
General database connection pool information, automatic after session condition monitoring, session failure in connection pool is arranged in configuration file
Reconstruction procedures;The encapsulation of database universal method include inquiry, paging query, deletion, batch deletion, modification, batch modification, newly
It builds, batch is newly-built, primary key generation strategies.
Wherein, database connection pool is constructed, comprising:
Obtain configuration information, wherein the configuration information include database IP address, user name, password, connection pool size,
Connection pool survival number, connection pool out-of-service time, connection pool monitor state detection sentence etc.;
The initialization of session information in connection pool is completed by configuration information, is increased in timed task detection connection pool
The availability of session, it is unavailable, it directly reconstructs.
Wherein, the management of Session life cycle: session is obtained, using session, closing session;
The general configuration information of database connection pool is arranged by configuration file for step 1.;
Step 2. reads the Initialize installation completion that configuration file completes database connection;
Step 3. uses the state of session in the connection pool of timed task monitoring data library, and completes failure session
Automatic Reconstruction;
Step 4. records session life cycle;
Step 5. encapsulation of data library generic configuration file.
The method that application example of the present invention provides, obtains the life state information of the session connection of database, and according to institute
The life state information for stating session connection, detects the availability of the session connection, when detecting that the session connection is unavailable
When, not available session connection is handled, realizes to the maintenance of the availability of session connection, improves the stabilization of session connection
Property.
Fig. 2 is the structure chart of the managing device of the session connection of database provided by the invention.Fig. 2 shown device includes:
Obtain module 201, the life state information of the session connection for obtaining database;
Detection module 202 detects the available of the session connection for the life state information according to the session connection
Property;
Processing module 203, for when detecting that the session connection is unavailable, at not available session connection
Reason.
In one exemplary embodiment, the acquisition module 201 includes:
First acquisition unit is connected for obtaining the target session that life state is use state;
Detection unit, the availability for connecting to the target session detect, and obtain testing result.
In one exemplary embodiment, the detection module 202 includes:
First detection unit, for detecting whether the session connection terminates;
First processing units judge whether the session connection can be normal if be not finished for the session connection
Data are transmitted, the first judging result is obtained, if first judging result is to be unable to normal transmission data, it is determined that the meeting
Words connection is unavailable;Alternatively, judging whether the session connection disconnects and the database if the session connection terminates
Connection, the second judging result is obtained, if second judging result is the connection not disconnected with the database, it is determined that
The session connection is unavailable.
In one exemplary embodiment, the processing module 203 includes:
Second acquisition unit, for obtaining the connection configuration information of the not available session connection;
Reconstruction unit, for being rebuild to the not available session connection according to the connection configuration information.
In one exemplary embodiment, the processing module 203 further include:
Second detection unit, for after rebuilding to the not available session connection, detection to be executed to rebuild and be grasped
Whether session connection is working properly after work;
Output unit, if still unavailable to session connection after the reconstruction operation for detecting, output is described not
The warning information of available session connection.
Installation practice provided by the invention obtains the life state information of the session connection of database, and according to described
The life state information of session connection, detects the availability of the session connection, when detecting that the session connection is unavailable,
Not available session connection is handled, realizes to the maintenance of the availability of session connection, improves the stability of session connection.
It will appreciated by the skilled person that whole or certain steps, system, dress in method disclosed hereinabove
Functional module/unit in setting may be implemented as software, firmware, hardware and its combination appropriate.In hardware embodiment,
Division between the functional module/unit referred in the above description not necessarily corresponds to the division of physical assemblies;For example, one
Physical assemblies can have multiple functions or a function or step and can be executed by several physical assemblies cooperations.Certain groups
Part or all components may be implemented as by processor, such as the software that digital signal processor or microprocessor execute, or by
It is embodied as hardware, or is implemented as integrated circuit, such as specific integrated circuit.Such software can be distributed in computer-readable
On medium, computer-readable medium may include computer storage medium (or non-transitory medium) and communication media (or temporarily
Property medium).As known to a person of ordinary skill in the art, term computer storage medium is included in for storing information (such as
Computer readable instructions, data structure, program module or other data) any method or technique in the volatibility implemented and non-
Volatibility, removable and nonremovable medium.Computer storage medium include but is not limited to RAM, ROM, EEPROM, flash memory or its
His memory technology, CD-ROM, digital versatile disc (DVD) or other optical disc storages, magnetic holder, tape, disk storage or other
Magnetic memory apparatus or any other medium that can be used for storing desired information and can be accessed by a computer.This
Outside, known to a person of ordinary skill in the art to be, communication media generally comprises computer readable instructions, data structure, program mould
Other data in the modulated data signal of block or such as carrier wave or other transmission mechanisms etc, and may include any information
Delivery media.
Claims (10)
1. a kind of management method of the session connection of database characterized by comprising
Obtain the life state information of the session connection of database;
According to the life state information of the session connection, the availability of the session connection is detected;
When detecting that the session connection is unavailable, not available session connection is handled.
2. the method according to claim 1, wherein the life state information according to the session connection,
Detect the availability of the session connection, comprising:
The target session that life state is use state is obtained to connect;
The availability of target session connection is detected, testing result is obtained.
3. method according to claim 1 or 2, which is characterized in that described to be believed according to the life state of the session connection
Breath, detects the availability of the session connection, comprising:
Detect whether the session connection terminates;
If the session connection is not finished, judge the session connection whether can normal transmission data, obtain the first judgement
As a result;If first judging result is to be unable to normal transmission data, it is determined that the session connection is unavailable;
If the session connection terminates, judge whether the session connection disconnects the connection with the database, obtains
Two judging results;If second judging result is the connection not disconnected with the database, it is determined that the session connection
It is unavailable.
4. method according to claim 1 or 2, which is characterized in that described to handle not available session connection, packet
It includes:
Obtain the connection configuration information of the not available session connection;
According to the connection configuration information, the not available session connection is rebuild.
5. according to right want 4 described in method, which is characterized in that it is described according to the connection configuration information, to described unavailable
Session connection rebuild after, the method also includes:
Whether session connection is working properly after detection executes reconstruction operation;
If detecting still unavailable to session connection after the reconstruction operation, the announcement of the not available session connection is exported
Alert information.
6. a kind of managing device of the session connection of database characterized by comprising
Obtain module, the life state information of the session connection for obtaining database;
Detection module detects the availability of the session connection for the life state information according to the session connection;
Processing module, for handling not available session connection when detecting that the session connection is unavailable.
7. device according to claim 6, which is characterized in that the acquisition module includes:
First acquisition unit is connected for obtaining the target session that life state is use state;
Detection unit, the availability for connecting to the target session detect, and obtain testing result.
8. device according to claim 6 or 7, which is characterized in that the detection module includes:
First detection unit, for detecting whether the session connection terminates;
First processing units judge whether the session connection being capable of normal transmission if be not finished for the session connection
Data obtain the first judging result, if first judging result is to be unable to normal transmission data, it is determined that the session connects
It connects unavailable;Alternatively, judging whether the session connection disconnects the company with the database if the session connection terminates
It connects, obtains the second judging result, if second judging result is the connection not disconnected with the database, it is determined that described
Session connection is unavailable.
9. device according to claim 6 or 7, which is characterized in that the processing module includes:
Second acquisition unit, for obtaining the connection configuration information of the not available session connection;
Reconstruction unit, for being rebuild to the not available session connection according to the connection configuration information.
10. according to right want 9 described in device, which is characterized in that the processing module further include:
Second detection unit, for detecting after executing reconstruction operation after being rebuild to the not available session connection
Whether session connection is working properly;
If output unit exports described unavailable still unavailable to session connection after the reconstruction operation for detecting
Session connection warning information.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811345183.5A CN109299182A (en) | 2018-11-13 | 2018-11-13 | The management method and device of the session connection of database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811345183.5A CN109299182A (en) | 2018-11-13 | 2018-11-13 | The management method and device of the session connection of database |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109299182A true CN109299182A (en) | 2019-02-01 |
Family
ID=65146288
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811345183.5A Pending CN109299182A (en) | 2018-11-13 | 2018-11-13 | The management method and device of the session connection of database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109299182A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101588393A (en) * | 2009-07-02 | 2009-11-25 | 杭州华三通信技术有限公司 | Method of state management based on real-time session |
CN101800682A (en) * | 2010-03-29 | 2010-08-11 | 中兴通讯股份有限公司 | Bidirectional forwarding detection (BFD) method and device |
CN101997850A (en) * | 2009-08-12 | 2011-03-30 | 中兴通讯股份有限公司 | Call management method and device for IP (Internet Protocol) multimedia subsystem |
CN107463458A (en) * | 2017-08-08 | 2017-12-12 | 武汉微创光电股份有限公司 | A kind of IPSAN monitoring abnormal states and recovery system |
-
2018
- 2018-11-13 CN CN201811345183.5A patent/CN109299182A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101588393A (en) * | 2009-07-02 | 2009-11-25 | 杭州华三通信技术有限公司 | Method of state management based on real-time session |
CN101997850A (en) * | 2009-08-12 | 2011-03-30 | 中兴通讯股份有限公司 | Call management method and device for IP (Internet Protocol) multimedia subsystem |
CN101800682A (en) * | 2010-03-29 | 2010-08-11 | 中兴通讯股份有限公司 | Bidirectional forwarding detection (BFD) method and device |
CN107463458A (en) * | 2017-08-08 | 2017-12-12 | 武汉微创光电股份有限公司 | A kind of IPSAN monitoring abnormal states and recovery system |
Non-Patent Citations (1)
Title |
---|
武奇生主编: "《网络与TCP/IP协议》", 31 March 2010, 西安电子科技大学出版社 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104615497B (en) | A kind of processing method and processing device of thread suspension | |
BRPI0924489B1 (en) | methods and systems to identify the hierarchy bias of the identification code in medical priority dispatch systems | |
US10573155B2 (en) | Closed loop alarm management | |
CN108710684A (en) | ETL task datas source switch method, system, computer equipment and storage medium | |
US20170330438A1 (en) | Autonomous life monitor system | |
CN107590014A (en) | Fault detection method, device, system, electronic equipment, storage medium | |
CN114596521A (en) | Venous transfusion monitoring method and system based on vision measurement | |
WO2020015116A1 (en) | Database monitoring method and terminal device | |
WO2020211805A1 (en) | Method and device for acquiring basic parameters of person to be rescued | |
US20190326020A1 (en) | Video Conferencing and Virtual Appointments | |
CN111528135A (en) | Target object determination method and device, storage medium and electronic device | |
CN205459559U (en) | Multi -functional medical care system | |
CN109299182A (en) | The management method and device of the session connection of database | |
CN105225398B (en) | A kind of forest fire protection monitor supervision platform | |
CN112330910B (en) | Information processing method and device for fire early warning, storage medium and processor | |
US11990237B2 (en) | Method and computer-readable recording medium for using a self-describing module for updating data in a medical monitoring device | |
CN109818958A (en) | A kind of computer network intelligent monitor system | |
CN107292111B (en) | Information processing method and server | |
CN109615393A (en) | The follow-up processing method and processing device of breakpoint | |
CN111414829B (en) | Method and device for sending alarm information | |
CN109408104B (en) | Method and device for acquiring game integration information | |
CN104699968A (en) | Intelligent medical guide system and method | |
US20180007639A1 (en) | Radio frequency identification modes in patient monitoring | |
CN109445369A (en) | Tool goes out checking device for putting in storage and system | |
CN114373552A (en) | Emergency management method, system and equipment for food poisoning and infectious diseases |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190201 |