|
@@ -1,15 +1,15 @@
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -30,47 +30,48 @@ db = DBFactory.create(params)
|
|
|
db.open()
|
|
|
.....
|
|
|
"""
|
|
|
-from pwman.data.database import Database, DatabaseException
|
|
|
-
|
|
|
-import pwman.util.config as config
|
|
|
+from pwman.data.database import DatabaseException
|
|
|
|
|
|
|
|
|
def check_db_version(type):
|
|
|
if type == "SQLite":
|
|
|
try:
|
|
|
from pwman.data.drivers import sqlite
|
|
|
- except ImportError, e:
|
|
|
+ except ImportError:
|
|
|
raise DatabaseException("python-sqlite not installed")
|
|
|
ver = sqlite.check_db_version()
|
|
|
return ver
|
|
|
|
|
|
-
|
|
|
-def create(type, version=None):
|
|
|
+
|
|
|
+
|
|
|
+def create(type, version=None, filename=None):
|
|
|
"""
|
|
|
create(params) -> Database
|
|
|
- Create a Database instance.
|
|
|
+ Create a Database instance.
|
|
|
'type' can only be 'SQLite' at the moment
|
|
|
"""
|
|
|
if (type == "SQLite"):
|
|
|
- try:
|
|
|
+ try:
|
|
|
from pwman.data.drivers import sqlite
|
|
|
- if version == 0.4:
|
|
|
+ if version == 0.4 and filename:
|
|
|
+ db = sqlite.SQLiteDatabaseNewForm(filename)
|
|
|
+ elif version == 0.4:
|
|
|
db = sqlite.SQLiteDatabaseNewForm()
|
|
|
else:
|
|
|
db = sqlite.SQLiteDatabase()
|
|
|
- except ImportError, e:
|
|
|
+ except ImportError:
|
|
|
raise DatabaseException("python-sqlite not installed")
|
|
|
elif (type == "Postgresql"):
|
|
|
try:
|
|
|
from pwman.data.drivers import postgresql
|
|
|
db = postgresql.PostgresqlDatabase()
|
|
|
- except ImportError, e:
|
|
|
+ except ImportError:
|
|
|
raise DatabaseException("python-pygresql not installed")
|
|
|
elif (type == "MySQL"):
|
|
|
try:
|
|
|
from pwman.data.drivers import mysql
|
|
|
db = mysql.MySQLDatabase()
|
|
|
- except ImportError, e:
|
|
|
+ except ImportError:
|
|
|
raise DatabaseException("python-mysqldb not installed")
|
|
|
else:
|
|
|
raise DatabaseException("Unknown database type specified")
|