Add exception for not being able to connect to MySQL, make use of it to pop up an error box
This commit is contained in:
parent
971a282383
commit
ee864033ee
|
@ -17,5 +17,8 @@ class FpdbParseError(FpdbError):
|
||||||
class FpdbDatabaseError(FpdbError):
|
class FpdbDatabaseError(FpdbError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class FpdbMySQLFailedError(FpdbDatabaseError):
|
||||||
|
pass
|
||||||
|
|
||||||
class DuplicateError(FpdbError):
|
class DuplicateError(FpdbError):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -76,7 +76,7 @@ import SQL
|
||||||
import Database
|
import Database
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
import Configuration
|
import Configuration
|
||||||
from Exceptions import *
|
import Exceptions
|
||||||
|
|
||||||
VERSION = "0.11"
|
VERSION = "0.11"
|
||||||
|
|
||||||
|
@ -453,7 +453,12 @@ class fpdb:
|
||||||
self.db.disconnect()
|
self.db.disconnect()
|
||||||
|
|
||||||
self.sql = SQL.Sql(type = self.settings['db-type'], db_server = self.settings['db-server'])
|
self.sql = SQL.Sql(type = self.settings['db-type'], db_server = self.settings['db-server'])
|
||||||
|
try:
|
||||||
self.db = Database.Database(self.config, sql = self.sql)
|
self.db = Database.Database(self.config, sql = self.sql)
|
||||||
|
except Exceptions.FpdbMySQLFailedError:
|
||||||
|
self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
|
||||||
if self.db.fdb.wrongDbVersion:
|
if self.db.fdb.wrongDbVersion:
|
||||||
diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||||
|
|
|
@ -80,7 +80,7 @@ class fpdb_db:
|
||||||
try:
|
try:
|
||||||
self.db = MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True)
|
self.db = MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True)
|
||||||
except:
|
except:
|
||||||
raise FpdbError("MySQL connection failed")
|
raise FpdbMySQLFailedError("MySQL connection failed")
|
||||||
elif backend==fpdb_db.PGSQL:
|
elif backend==fpdb_db.PGSQL:
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user