| Trees | Indices | Help |
|---|
|
|
1 #
2 # Copyright (c) 2008--2013 Red Hat, Inc.
3 #
4 # This software is licensed to you under the GNU General Public License,
5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or
6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
8 # along with this software; if not, see
9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
10 #
11 # Red Hat trademarks are not licensed under GPLv2. No permission is
12 # granted to use or replicate Red Hat trademarks that are incorporated
13 # in this software or its documentation.
14 #
15 #
16
17 from const import ORACLE, POSTGRESQL
18
19 # Map supported backend constants to a specific Python driver:
20 BACKEND_DRIVERS = {
21 ORACLE: "cx_Oracle",
22 POSTGRESQL: "postgresql",
23 }
24
25
27 """Loads the database driver module, performing autodetection if needed"""
28
29 # Assume Oracle if no backend is specified:
30 if backend is None:
31 driver = BACKEND_DRIVERS[ORACLE]
32 else:
33 driver = BACKEND_DRIVERS[backend]
34
35 driver_dir = "spacewalk.server.rhnSQL"
36 driver_mod = "driver_" + driver
37 try:
38 module = __import__(driver_dir, globals(), locals(), [driver_mod])
39 module = getattr(module, driver_mod)
40 except ImportError:
41 raise
42
43 return module
44
45
47 """Returns the database class"""
48 module = get_database_module(backend=backend)
49 return module.Database
50
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:43 2020 | http://epydoc.sourceforge.net |