当前位置: 首页>>代码示例>>Python>>正文


Python Message.TEXT方法代码示例

本文整理汇总了Python中Message.Message.TEXT方法的典型用法代码示例。如果您正苦于以下问题:Python Message.TEXT方法的具体用法?Python Message.TEXT怎么用?Python Message.TEXT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message.Message的用法示例。


在下文中一共展示了Message.TEXT方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_messages

# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import TEXT [as 别名]
    def get_messages(self, ID):
        connection = pymysql.connect(host=db.db_host, port=db.db_port, user=db.db_user, passwd=db.db_passwd, db=db.db_name)
        cursor = connection.cursor()

        #Conseguir último mensaje individual.
        SQL = """SELECT MAX(SEND_INDIVIDUAL_MESSAGE.ID_MESSAGE) AS MAX_INDIVIDUAL
                 FROM SEND_INDIVIDUAL_MESSAGE""".replace('\n',' ')

        cursor.execute(SQL)
        maxI = cursor._rows[0][0]

        #Conseguir último mensaje grupal.
        SQL = """SELECT MAX(SEND_MESSAGE_GROUP.ID_MESSAGE) AS MAX_GROUP
                FROM SEND_MESSAGE_GROUP""".replace('\n',' ')

        cursor.execute(SQL)
        maxG = cursor._rows[0][0]

        if maxG is None:
            maxG = 0

        if maxI is None:
            maxI = 0

        #Recibir mensajes
        SQL = """SELECT ID_USER_SENDER, MESSAGES.TEXT, 0 AS ID_GROUP, (SELECT U.PHONE FROM USERS U WHERE U.ID_USER = ID_USER_SENDER) AS SENDER_PHONE
                 FROM USERS, MESSAGES, SEND_INDIVIDUAL_MESSAGE
                 WHERE USERS.ID_USER = SEND_INDIVIDUAL_MESSAGE.ID_USER_RECEIVER
                     AND SEND_INDIVIDUAL_MESSAGE.ID_MESSAGE = MESSAGES.ID_MESSAGE
                     AND USERS.ID_USER = %s
                     AND MESSAGES.ID_MESSAGE > USERS.LAST_RECEIVED_MESSAGE_INDIVIDUAL
                     AND MESSAGES.ID_MESSAGE <= %s
                 UNION
                 SELECT SEND_MESSAGE_GROUP.ID_USER AS ID_USER_SENDER, MESSAGES.TEXT , BELONG.ID_GROUP, (SELECT U.PHONE FROM USERS U WHERE U.ID_USER = ID_USER_SENDER) AS SENDER_PHONE
                 FROM USERS , MESSAGES , SEND_MESSAGE_GROUP , BELONG
                 WHERE USERS.ID_USER = BELONG.ID_USER
                     AND BELONG.ID_GROUP = SEND_MESSAGE_GROUP.ID_GROUP
                     AND SEND_MESSAGE_GROUP.ID_MESSAGE = MESSAGES.ID_MESSAGE
                     AND USERS.ID_USER = %s
                     AND SEND_MESSAGE_GROUP.ID_USER != USERS.ID_USER
                     AND MESSAGES.ID_MESSAGE > USERS.LAST_RECEIVED_MESSAGE_GROUP
                     AND MESSAGES.ID_MESSAGE <= %s;""".replace('\n',' ')

					  
        SQL = SQL % (str(ID),str(maxI),str(ID),str(maxG))
        cursor.execute(SQL)

        messages = list()
        for row in cursor:
            message = Message()
            message.ID_USER_SENDER = row[0]
            message.TEXT = row[1]
            message.ID_GROUP = row[2]
            message.PHONE = row[3]

            messages.append(message.serialize())

        #Actualizar ultimo mensaje.
        SQL = """UPDATE USERS
	             SET USERS.LAST_RECEIVED_MESSAGE_INDIVIDUAL = %s ,
		             USERS.LAST_RECEIVED_MESSAGE_GROUP = %s
	             WHERE USERS.ID_USER = %s ;""".replace('\n',' ').replace('\t','')

        SQL = SQL % (str(maxI),str(maxG),str(ID))
        cursor.execute(SQL)
        connection.commit()

        cursor.close()
        return messages
开发者ID:josewer,项目名称:Android-Chat,代码行数:71,代码来源:DataBase.py


注:本文中的Message.Message.TEXT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。