Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Aug 1, 2022
1 parent 862aace commit 1b6621c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 126 deletions.
10 changes: 0 additions & 10 deletions class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,3 @@ def getMyORMDb():
import ormDb
o = ormDb.ORM()
return o


def getMyORMMariaDb():
'''
获取MariaDB资源的ORM | pip install mariadb
'''
sys.path.append(os.getcwd() + "/class/plugin")
import mariaDb
o = mariaDb.ORM()
return o
93 changes: 0 additions & 93 deletions class/plugin/mariaDb.py

This file was deleted.

27 changes: 9 additions & 18 deletions class/plugin/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import sys

from mysql import connector
import pymysql.cursors


class ORM:
Expand All @@ -21,25 +21,16 @@ class ORM:
__DB_CHARSET = "utf8"

def __Conn(self):
'''连接MYSQL数据库'''
'''连接数据库'''
try:

if os.path.exists(self.__DB_SOCKET):
try:
self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET)
except Exception as e:
self.__DB_HOST = '127.0.0.1'
self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET)
else:
try:
self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1)
except Exception as e:
self.__DB_HOST = '127.0.0.1'
self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1)
try:
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, cursorclass=pymysql.cursors.DictCursor)
except Exception as e:
self.__DB_HOST = '127.0.0.1'
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, cursorclass=pymysql.cursors.DictCursor)

self.__DB_CUR = self.__DB_CONN.cursor()
return True
Expand Down
6 changes: 3 additions & 3 deletions plugins/mariadb/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def pSqliteDb(dbname='databases'):


def pMysqlDb():
# mysql.connector
# db = mw.getMyORM()
# pymysql
db = mw.getMyORM()
# MySQLdb |
db = mw.getMyORMMariaDb()
# db = mw.getMyORMDb()

db.setDbConf(getConf())
db.setPort(getDbPort())
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ pymongo
pillow
Jinja2>=2.11.2
flask-caching>=1.10.1
PyMySQL
mysql-connector-python
2 changes: 0 additions & 2 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirem
pip3 install gevent-websocket==0.10.1
pip3 install flask-caching==1.10.1
pip3 install mysqlclient
# pip3 install mariadb


if [ ! -f /www/server/mdserver-web/bin/activate ];then
Expand All @@ -131,5 +130,4 @@ pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gevent-websocket==0.10.1
pip3 install flask-caching==1.10.1
pip3 install mysqlclient
# pip3 install mariadb

0 comments on commit 1b6621c

Please sign in to comment.