Ejemplo n.º 1
0
 def RegistAccount(self, conn, data):
     id, pw = data.split("|", 1)
     rows = Mysql.getInstance().execute("select * from `accounts` where `id` = '"+ id + "'")
     if rows:
         conn.send(SendPacketHeader.RegistNO, "중복된 아이디 입니다!")
     else:
         Mysql.getInstance().execute("INSERT INTO accounts VALUES(0, '"+ id +"', '"+ pw +"')")
         conn.send(SendPacketHeader.RegistOK, "회원가입이 완료되었습니다!")
Ejemplo n.º 2
0
 def addUserTypeData(self, userkey, data):
     for item in data:
         item = self.removeBranch(item)
         category = Mysql.getInstance().execute(
             "SELECT `category` from `restaurant` where `name` LIKE '" +
             str(item) + "%';")
         if category:
             Mysql.getInstance().execute(
                 "INSERT INTO `paymentdata` VALUES(" + str(userkey) +
                 ", '" + str(item) + "', " + str(category[0][0]) + ");")
Ejemplo n.º 3
0
 def LoginRequest(self, conn, data):
     id, pw = data.split("|", 1)
     rows = Mysql.getInstance().execute("select * from `accounts` where `id` = '"+ id + "' and `pw` = '" + pw + "'")
     if rows:
         conn.send(SendPacketHeader.LoginOK, "로그인이 완료되었습니다")
         conn.id = id
         conn.key = int(rows[0][0])
     else:
         conn.send(SendPacketHeader.LoginNO, "로그인에 실패했습니다")
Ejemplo n.º 4
0
    def getUserType(self, userkey):
        result = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        #userkey = Mysql.getInstance().execute("select `key` from `accounts` where `id` = '" + str(userid) + "';")
        datas = Mysql.getInstance().execute(
            "select `category` from paymentdata where `userkey` = " +
            str(userkey) + ";")
        for data in datas:
            result[int(data[0])] += 1

        return result
Ejemplo n.º 5
0
    def getRestaurantType(self, data):
        result = list()
        for item in data:
            matchitem = self.removeBranch(item)

            category = Mysql.getInstance().execute(
                "select `category`, `name` from `restaurant` where `name` LIKE '"
                + str(matchitem) + "%';")
            if category:
                result.append([item, int(category[0][0])])
            else:
                print(item + "가 존재하지 않습니다.")
                result.append([item, -1])

        return result
Ejemplo n.º 6
0
from db.Mysql import Mysql

StockDb = Mysql('stock')
Ejemplo n.º 7
0
import socket
import Server
import ServerThread
from db.Mysql import Mysql

# SERVER SETTING
hostip = '172.30.1.33'
port = 5882

#SOCKET INITIALIZE
try:
    soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    soc.bind((hostip, port))
    soc.listen()
    print(soc.getsockname()[0] +":"+str(port)+" IS READY !!")
except:
    print("SOCKET OPEN ERROR")
    exit(1)

Mysql.instance()
st = ServerThread.ServerThread()

while True:
    print("SOCKET IS WAITING FOR ACCEPTING..")
    conn, addr = soc.accept()
    c = Server.Server(conn, addr).start()
    st.append(st)

soc.close()