updated README and database test
parent
4f4b5d52c6
commit
658160e1be
|
@ -175,12 +175,14 @@ sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
|
|||
|
||||
**3.3** 测试数据库是否可以正确连接
|
||||
```
|
||||
python3 myems/database/test_mysql.py
|
||||
cd myems
|
||||
cp myems-api/.env database/
|
||||
python3 database/test_mysql.py
|
||||
```
|
||||
注:如果测试通过,继续下一步操作,否则请修改.env配置,确保数据库可以通过Python3正常连接访问。
|
||||
注:如果测试通过,继续下一步操作,否则请修改.env配置。
|
||||
|
||||
|
||||
- 4.web打包 (myems/web为React项目,需要打包为产品文件)
|
||||
- 4.web打包 (Web UI 为React项目,需要打包为产品文件)
|
||||
|
||||
```
|
||||
cd myems/web
|
||||
|
@ -197,7 +199,6 @@ docker-compose up -d
|
|||
```
|
||||
|
||||
|
||||
|
||||
- 6.测试
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
### Introduction
|
||||
|
||||
Providing database schema and scripts for MyEMS.
|
||||
Database schema and scripts for MyEMS.
|
||||
|
||||
### Prerequisites
|
||||
[MySQL 8.0 or later](https://www.mysql.com/)
|
||||
[MySQL 8.0 (64bit) or later](https://www.mysql.com/)
|
||||
|
||||
or [MariaDB 10.5 or later](https://mariadb.org/)
|
||||
or
|
||||
|
||||
or [SingleStore 7.0 or later](https://www.singlestore.com/) (highly recommended)
|
||||
[MariaDB 10.5 (64bit) or later](https://mariadb.org/)
|
||||
|
||||
or
|
||||
|
||||
[SingleStore 7.0 or later](https://www.singlestore.com/)
|
||||
|
||||
### Installation
|
||||
|
||||
|
@ -56,6 +60,8 @@ set global net_buffer_length=1000000;
|
|||
set global max_allowed_packet=1000000000;
|
||||
```
|
||||
|
||||
#### Don't Install Database in Docker
|
||||
|
||||
### Database Definition
|
||||
|
||||
#### myems_billing_baseline_db
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
import mysql.connector
|
||||
import config
|
||||
from decouple import config
|
||||
|
||||
|
||||
def test_connect():
|
||||
if __name__ == "__main__":
|
||||
|
||||
myems_system_db = {
|
||||
'host': config('MYEMS_SYSTEM_DB_HOST', default='127.0.0.1'),
|
||||
'port': config('MYEMS_SYSTEM_DB_PORT', default=3306, cast=int),
|
||||
'database': config('MYEMS_SYSTEM_DB_DATABASE', default='myems_system_db'),
|
||||
'user': config('MYEMS_SYSTEM_DB_USER', default='root'),
|
||||
'password': config('MYEMS_SYSTEM_DB_PASSWORD', default='!MyEMS1'),
|
||||
}
|
||||
|
||||
cursor = None
|
||||
cnx = None
|
||||
try:
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cnx = mysql.connector.connect(**myems_system_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
query = (" SELECT id, name, display_name, email "
|
||||
" FROM tbl_users "
|
||||
" ORDER BY id ")
|
||||
query = (" SELECT version "
|
||||
" FROM tbl_versions "
|
||||
" WHERE id = 1 ")
|
||||
cursor.execute(query)
|
||||
rows = cursor.fetchall()
|
||||
print("The config of database is right:", rows)
|
||||
row = cursor.fetchone()
|
||||
if row is not None and len(row) > 0:
|
||||
print("The database version is : ", str(row[0]))
|
||||
except Exception as e:
|
||||
print("The config of database is wrong:", str(e))
|
||||
print("There is something wrong with database :", str(e))
|
||||
finally:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_connect()
|
||||
|
|
Loading…
Reference in New Issue