-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_test.py
executable file
·58 lines (44 loc) · 1.65 KB
/
mysql_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
# plantagenet - a python blogging system
# Copyright (C) 2016-2017 izrik
#
# This file is a part of plantagenet.
#
# Plantagenet is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Plantagenet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with plantagenet. If not, see <http://www.gnu.org/licenses/>.
import argparse
from os import environ
import MySQLdb
class Config(object):
PASSWORD = environ.get('PASSWORD')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('host', type=str, action='store')
parser.add_argument('user', type=str, action='store')
parser.add_argument('--password', type=str, action='store',
default=Config.PASSWORD)
parser.add_argument('db', type=str, action='store')
parser.add_argument('--ssl-cert', type=str, action='store')
parser.add_argument('--ssl-key', type=str, action='store')
args = parser.parse_args()
Config.PASSWORD = args.password
def run():
print('DB URI: {}'.format(Config.DB_URI))
conn = MySQLdb.connect(
host=args.host,
user=args.user,
passwd=Config.PASSWORD,
db=args.db,
)
if __name__ == "__main__":
run()