you can manually add points to database
This commit is contained in:
parent
93bb634f7c
commit
a22d1e6ddb
24
database.py
24
database.py
|
@ -10,9 +10,16 @@ parser.add_argument(
|
||||||
help="Choose a file",
|
help="Choose a file",
|
||||||
type=argparse.FileType('r')
|
type=argparse.FileType('r')
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-m",
|
||||||
|
"--manual",
|
||||||
|
help="add point manually do database",
|
||||||
|
dest="manual",
|
||||||
|
action="store_true"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
MANUAL = args.manual
|
||||||
|
|
||||||
config_path = "./user_data/config.cfg"
|
config_path = "./user_data/config.cfg"
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
@ -47,7 +54,7 @@ def ban_account(name: str, pts = 0):
|
||||||
def update_pts(name: str, pts = 0):
|
def update_pts(name: str, pts = 0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if not MANUAL :
|
||||||
print("ajouter un compte : 1\nban un compte : 2")
|
print("ajouter un compte : 1\nban un compte : 2")
|
||||||
i = input()
|
i = input()
|
||||||
if i == "1":
|
if i == "1":
|
||||||
|
@ -70,3 +77,16 @@ elif i == '2':
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
mycursor.close()
|
mycursor.close()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
|
else :
|
||||||
|
import modules.db as datab
|
||||||
|
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/MsRewards/user_data/config.cfg"
|
||||||
|
print(config_path)
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(config_path)
|
||||||
|
sql_usr = config["SQL"]["usr"]
|
||||||
|
sql_pwd = config["SQL"]["pwd"]
|
||||||
|
sql_host = config["SQL"]["host"]
|
||||||
|
sql_database = config["SQL"]["database"]
|
||||||
|
account_name = input("compte ? ")
|
||||||
|
points = int(input("points ? "))
|
||||||
|
datab.add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database)
|
Loading…
Reference in New Issue