get_connection(...) Returns the connection object for the certain connection-id/database for the specific server, identified by sid. Create a new Connection object (if require). If server id is 0, it will return the database connection object. Param
(
self, sid, database=None, conn_id=None, auto_reconnect=True,
**kwargs
)
| 192 | ) |
| 193 | |
| 194 | def get_connection( |
| 195 | self, sid, database=None, conn_id=None, auto_reconnect=True, |
| 196 | **kwargs |
| 197 | ): |
| 198 | """ |
| 199 | get_connection(...) |
| 200 | |
| 201 | Returns the connection object for the certain connection-id/database |
| 202 | for the specific server, identified by sid. Create a new Connection |
| 203 | object (if require). If server id is 0, it will return the database |
| 204 | connection object. |
| 205 | |
| 206 | Parameters: |
| 207 | sid |
| 208 | - Server ID |
| 209 | database |
| 210 | - Database, on which the connection needs to be made |
| 211 | If provided none, maintenance_db for the server will be used, |
| 212 | while generating new Connection object. |
| 213 | conn_id |
| 214 | - Identification String for the Connection This will be used by |
| 215 | certain tools, which will require a dedicated connection for it. |
| 216 | i.e. Debugger, Query Tool, etc. |
| 217 | auto_reconnect |
| 218 | - This parameters define, if we should attempt to reconnect the |
| 219 | database server automatically, when connection has been lost for |
| 220 | any reason. Certain tools like Debugger will require a permenant |
| 221 | connection, and it stops working on disconnection. |
| 222 | |
| 223 | """ |
| 224 | |
| 225 | if sid: |
| 226 | manager = self.connection_manager(sid) |
| 227 | |
| 228 | return manager.connection(database=database, conn_id=conn_id, |
| 229 | auto_reconnect=auto_reconnect) |
| 230 | else: |
| 231 | return psycopg.Connection.connect( |
| 232 | host=kwargs['host'], |
| 233 | dbname=database, |
| 234 | user=kwargs['user'], |
| 235 | password=kwargs[ |
| 236 | 'password'] if 'password' in kwargs else None, |
| 237 | port=kwargs['port'] if |
| 238 | kwargs['port'] else None, |
| 239 | passfile=kwargs['passfile'], |
| 240 | connect_timeout=kwargs['connect_timeout'] if |
| 241 | 'connect_timeout' in kwargs and |
| 242 | kwargs['connect_timeout'] else 0, |
| 243 | sslmode=kwargs['sslmode'], |
| 244 | sslcert=kwargs['sslcert'], |
| 245 | sslkey=kwargs['sslkey'], |
| 246 | sslrootcert=kwargs['sslrootcert'], |
| 247 | sslcompression=True if kwargs[ |
| 248 | 'sslcompression'] else False |
| 249 | ) |
| 250 | |
| 251 | def release_connection(self, sid, database=None, conn_id=None): |
nothing calls this directly
no test coverage detected