Prepare setuptools for MySQL support
This commit is contained in:
parent
23218aff75
commit
6297f37bd7
1 changed files with 38 additions and 4 deletions
|
@ -2,19 +2,53 @@ import configparser, csv, datetime, html.parser, itertools, os, sqlite3, sys, tw
|
|||
|
||||
class SetupException(Exception):
|
||||
def __str__(self):
|
||||
return "Seems like config.cfg has not been created yet. Run setup.py to do so."
|
||||
return "Seems like config.cfg has not been created yet or contains serious errors. Run setup.py to create it."
|
||||
|
||||
|
||||
def getSetting(section, setting):
|
||||
def getSetting(section, setting, path = "config.cfg"):
|
||||
config = configparser.RawConfigParser()
|
||||
config.read('config.cfg')
|
||||
config.read(path)
|
||||
return config.get(section, setting)
|
||||
|
||||
def dbtype():
|
||||
try:
|
||||
return getSetting("Database", "type")
|
||||
except:
|
||||
return 0 # for SQLite3
|
||||
|
||||
### Must only be called AFTER dbtype()! ###
|
||||
|
||||
def dbhost():
|
||||
try:
|
||||
return getSetting("Database", "host")
|
||||
except:
|
||||
raise SetupException()
|
||||
|
||||
def dbuser():
|
||||
try:
|
||||
return getSetting("Database", "user")
|
||||
except:
|
||||
raise SetupException()
|
||||
|
||||
def dbpass():
|
||||
try:
|
||||
return getSetting("Database", "pass")
|
||||
except:
|
||||
raise SetupException()
|
||||
|
||||
def dbname():
|
||||
try:
|
||||
return getSetting("Database", "name")
|
||||
except:
|
||||
raise SetupException()
|
||||
|
||||
def dbpath():
|
||||
try:
|
||||
return getSetting("Database", "path")
|
||||
except:
|
||||
return "Database.db"
|
||||
return SetupException()
|
||||
|
||||
###
|
||||
|
||||
def cke():
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue