Skip to content

Commit 4f335e3

Browse files
committed
feat (MySQL): autoformat
1 parent 6954e65 commit 4f335e3

File tree

1 file changed

+98
-97
lines changed

1 file changed

+98
-97
lines changed

src/DIRAC/Core/Utilities/MySQL.py

Lines changed: 98 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,152 @@
1-
""" DIRAC Basic MySQL Class
2-
It provides access to the basic MySQL methods in a multithread-safe mode
3-
keeping used connections in a python Queue for further reuse.
1+
"""DIRAC Basic MySQL Class
2+
It provides access to the basic MySQL methods in a multithread-safe mode
3+
keeping used connections in a python Queue for further reuse.
44
5-
These are the coded methods:
5+
These are the coded methods:
66
77
8-
__init__( host, user, passwd, name, [maxConnsInQueue=10] )
8+
__init__( host, user, passwd, name, [maxConnsInQueue=10] )
99
10-
Initializes the Queue and tries to connect to the DB server,
11-
using the _connect method.
12-
"maxConnsInQueue" defines the size of the Queue of open connections
13-
that are kept for reuse. It also defined the maximum number of open
14-
connections available from the object.
15-
maxConnsInQueue = 0 means unlimited and it is not supported.
10+
Initializes the Queue and tries to connect to the DB server,
11+
using the _connect method.
12+
"maxConnsInQueue" defines the size of the Queue of open connections
13+
that are kept for reuse. It also defined the maximum number of open
14+
connections available from the object.
15+
maxConnsInQueue = 0 means unlimited and it is not supported.
1616
1717
18-
_except( methodName, exception, errorMessage )
18+
_except( methodName, exception, errorMessage )
1919
20-
Helper method for exceptions: the "methodName" and the "errorMessage"
21-
are printed with ERROR level, then the "exception" is printed (with
22-
full description if it is a MySQL Exception) and S_ERROR is returned
23-
with the errorMessage and the exception.
20+
Helper method for exceptions: the "methodName" and the "errorMessage"
21+
are printed with ERROR level, then the "exception" is printed (with
22+
full description if it is a MySQL Exception) and S_ERROR is returned
23+
with the errorMessage and the exception.
2424
2525
26-
_connect()
26+
_connect()
2727
28-
Attempts connection to DB and sets the _connected flag to True upon success.
29-
Returns S_OK or S_ERROR.
28+
Attempts connection to DB and sets the _connected flag to True upon success.
29+
Returns S_OK or S_ERROR.
3030
3131
32-
_query( cmd, [conn=conn] )
32+
_query( cmd, [conn=conn] )
3333
34-
Executes SQL command "cmd".
35-
Gets a connection from the Queue (or open a new one if none is available),
36-
the used connection is back into the Queue.
37-
If a connection to the the DB is passed as second argument this connection
38-
is used and is not in the Queue.
39-
Returns S_OK with fetchall() out in Value or S_ERROR upon failure.
34+
Executes SQL command "cmd".
35+
Gets a connection from the Queue (or open a new one if none is available),
36+
the used connection is back into the Queue.
37+
If a connection to the the DB is passed as second argument this connection
38+
is used and is not in the Queue.
39+
Returns S_OK with fetchall() out in Value or S_ERROR upon failure.
4040
4141
42-
_update( cmd, [conn=conn] )
42+
_update( cmd, [conn=conn] )
4343
44-
Executes SQL command "cmd" and issue a commit
45-
Gets a connection from the Queue (or open a new one if none is available),
46-
the used connection is back into the Queue.
47-
If a connection to the the DB is passed as second argument this connection
48-
is used and is not in the Queue
49-
Returns S_OK with number of updated registers in Value or S_ERROR upon failure.
44+
Executes SQL command "cmd" and issue a commit
45+
Gets a connection from the Queue (or open a new one if none is available),
46+
the used connection is back into the Queue.
47+
If a connection to the the DB is passed as second argument this connection
48+
is used and is not in the Queue
49+
Returns S_OK with number of updated registers in Value or S_ERROR upon failure.
5050
5151
52-
_createTables( tableDict )
52+
_createTables( tableDict )
5353
54-
Create a new Table in the DB
54+
Create a new Table in the DB
5555
5656
57-
_getConnection()
57+
_getConnection()
5858
59-
Gets a connection from the Queue (or open a new one if none is available)
60-
Returns S_OK with connection in Value or S_ERROR
61-
the calling method is responsible for closing this connection once it is no
62-
longer needed.
59+
Gets a connection from the Queue (or open a new one if none is available)
60+
Returns S_OK with connection in Value or S_ERROR
61+
the calling method is responsible for closing this connection once it is no
62+
longer needed.
6363
6464
6565
6666
67-
Some high level methods have been added to avoid the need to write SQL
68-
statement in most common cases. They should be used instead of low level
69-
_insert, _update methods when ever possible.
67+
Some high level methods have been added to avoid the need to write SQL
68+
statement in most common cases. They should be used instead of low level
69+
_insert, _update methods when ever possible.
7070
71-
buildCondition( self, condDict = None, older = None, newer = None,
72-
timeStamp = None, orderAttribute = None, limit = False,
73-
greater = None, smaller = None ):
71+
buildCondition( self, condDict = None, older = None, newer = None,
72+
timeStamp = None, orderAttribute = None, limit = False,
73+
greater = None, smaller = None ):
7474
75-
Build SQL condition statement from provided condDict and other extra check on
76-
a specified time stamp.
77-
The conditions dictionary specifies for each attribute one or a List of possible
78-
values
79-
greater and smaller are dictionaries in which the keys are the names of the fields,
80-
that are requested to be >= or < than the corresponding value.
81-
For compatibility with current usage it uses Exceptions to exit in case of
82-
invalid arguments
75+
Build SQL condition statement from provided condDict and other extra check on
76+
a specified time stamp.
77+
The conditions dictionary specifies for each attribute one or a List of possible
78+
values
79+
greater and smaller are dictionaries in which the keys are the names of the fields,
80+
that are requested to be >= or < than the corresponding value.
81+
For compatibility with current usage it uses Exceptions to exit in case of
82+
invalid arguments
8383
8484
85-
insertFields( self, tableName, inFields = None, inValues = None, conn = None, inDict = None ):
85+
insertFields( self, tableName, inFields = None, inValues = None, conn = None, inDict = None ):
8686
87-
Insert a new row in "tableName" assigning the values "inValues" to the
88-
fields "inFields".
89-
Alternatively inDict can be used
90-
String type values will be appropriately escaped.
87+
Insert a new row in "tableName" assigning the values "inValues" to the
88+
fields "inFields".
89+
Alternatively inDict can be used
90+
String type values will be appropriately escaped.
9191
9292
93-
updateFields( self, tableName, updateFields = None, updateValues = None,
94-
condDict = None,
95-
limit = False, conn = None,
96-
updateDict = None,
97-
older = None, newer = None,
98-
timeStamp = None, orderAttribute = None ):
93+
updateFields( self, tableName, updateFields = None, updateValues = None,
94+
condDict = None,
95+
limit = False, conn = None,
96+
updateDict = None,
97+
older = None, newer = None,
98+
timeStamp = None, orderAttribute = None ):
9999
100-
Update "updateFields" from "tableName" with "updateValues".
101-
updateDict alternative way to provide the updateFields and updateValues
102-
N records can match the condition
103-
return S_OK( number of updated rows )
104-
if limit is not False, the given limit is set
105-
String type values will be appropriately escaped.
100+
Update "updateFields" from "tableName" with "updateValues".
101+
updateDict alternative way to provide the updateFields and updateValues
102+
N records can match the condition
103+
return S_OK( number of updated rows )
104+
if limit is not False, the given limit is set
105+
String type values will be appropriately escaped.
106106
107107
108-
deleteEntries( self, tableName,
109-
condDict = None,
110-
limit = False, conn = None,
111-
older = None, newer = None,
112-
timeStamp = None, orderAttribute = None ):
113-
114-
Delete rows from "tableName" with
115-
N records can match the condition
116-
if limit is not False, the given limit is set
117-
String type values will be appropriately escaped, they can be single values or lists of values.
118-
119-
120-
getFields( self, tableName, outFields = None,
108+
deleteEntries( self, tableName,
121109
condDict = None,
122110
limit = False, conn = None,
123111
older = None, newer = None,
124112
timeStamp = None, orderAttribute = None ):
125113
126-
Select "outFields" from "tableName" with condDict
127-
N records can match the condition
128-
return S_OK( tuple(Field,Value) )
129-
if limit is not False, the given limit is set
130-
String type values will be appropriately escaped, they can be single values or lists of values.
114+
Delete rows from "tableName" with
115+
N records can match the condition
116+
if limit is not False, the given limit is set
117+
String type values will be appropriately escaped, they can be single values or lists of values.
118+
131119
132-
for compatibility with other methods condDict keyed argument is added
120+
getFields( self, tableName, outFields = None,
121+
condDict = None,
122+
limit = False, conn = None,
123+
older = None, newer = None,
124+
timeStamp = None, orderAttribute = None ):
133125
126+
Select "outFields" from "tableName" with condDict
127+
N records can match the condition
128+
return S_OK( tuple(Field,Value) )
129+
if limit is not False, the given limit is set
130+
String type values will be appropriately escaped, they can be single values or lists of values.
134131
135-
getCounters( self, table, attrList, condDict = None, older = None,
136-
newer = None, timeStamp = None, connection = False ):
132+
for compatibility with other methods condDict keyed argument is added
137133
138-
Count the number of records on each distinct combination of AttrList, selected
139-
with condition defined by condDict and time stamps
140134
135+
getCounters( self, table, attrList, condDict = None, older = None,
136+
newer = None, timeStamp = None, connection = False ):
141137
142-
getDistinctAttributeValues( self, table, attribute, condDict = None, older = None,
143-
newer = None, timeStamp = None, connection = False ):
138+
Count the number of records on each distinct combination of AttrList, selected
139+
with condition defined by condDict and time stamps
144140
145-
Get distinct values of a table attribute under specified conditions
141+
142+
getDistinctAttributeValues( self, table, attribute, condDict = None, older = None,
143+
newer = None, timeStamp = None, connection = False ):
144+
145+
Get distinct values of a table attribute under specified conditions
146146
147147
148148
"""
149+
149150
import collections
150151
import functools
151152
import json

0 commit comments

Comments
 (0)