def __init__(self): """ создает класс Connect и очередь сервера передает в класс Connect себя """ Thread.__init__(self) self.connect_class = Connect(self) self.server_thread = Server_Thread()
class Application(Thread): connect_class = None server_thread = None def __init__(self): """ создает класс Connect и очередь сервера передает в класс Connect себя """ Thread.__init__(self) self.connect_class = Connect(self) self.server_thread = Server_Thread() def run(self): self.server_thread.start() self.connect_class.start() self.connect_class.join() return
import pymysql from Connection import Connect dni = input("Ingrese el DNI de la persona a buscar: ") c = Connect() conn = c.openConnection() cur = conn.cursor() caux = "select * from persona where dni = '{}'".format(dni) try: cur.execute(caux) pers = cur.fetchone() cur.close() if pers[0] is None: print("No existe una persona con ese DNI") else: #for p in pers: print(pers) cur2 = conn.cursor() caux = "select * from personacorporal where idPersona = {}".format( pers[0]) cur2.execute(caux) peso = cur2.fetchall() cur2.close() for p in peso: print(p) except Exception as e: print('Got error {!r}, errno is {}'.format(e, e.args[0])) finally:
from discord.ext import commands from collections import OrderedDict from Connection import Connect import math import discord cluster = Connect.get_connect() db = cluster['emotes_db'] collection = db['emotes_collection'] class EmoteCommand(commands.Cog): def __init__(self, bot): self.bot = bot def create_emojis_dictionary(list_of_emojis): emojis_dict = {} emojis_id_field = collection.find({"emoji_id": { "$gt": -1 }}, { "_id": 0, "emoji_name": 0 }) count_field = collection.find({"count": { "$gt": -1 }}, { "_id": 0, "emoji_name": 0 }) emojis_id = [emoji_id["emoji_id"] for emoji_id in emojis_id_field]
from pymongo import MongoClient from Connection import Connect import pandas as pd import json # Read the csv file in pandas dataframe data = pd.read_csv("./sample_201501.csv") # convert data in json format before loading to mongodb data_json = json.loads(data.to_json(orient='records')) conn = Connect.get_connection() db = conn['foobar'] coll = db['flights'] coll.remove() coll.insert_many(data_json) print(coll.find_one())
def run(): print(vk_api.__file__) print("Server started") i = 0 monopoly = {} user = {} lobby = [[[], 0]] connect = Connect(lobby) button = "keyboard.json" while True: everyTime(connect, monopoly) # проверяем, истекло ли время messages = vk.method("messages.getConversations", { "offset": 0, "count": 20, "filter": "unread" }) if messages["count"] >= 1: print('New message:') print('For me by: ', end='') user_id = messages["items"][0]["last_message"]["from_id"] mes_user = messages["items"][0]["last_message"]["text"].upper() vk_methods = VkMethods(vk) name = vk_methods.getNameById(user_id) is_active, i_user = connect.getLobbyByIdUser(user_id) if not is_active == False: mes = '' for i in range(len(is_active[0])): mes = mes + str(is_active[0][i]) + ', ' print("Участник состоит в лобби: " + str(i_user)) print("Лобби: " + mes) if is_active == False: # ЕСЛИ ЛОББИ НЕ АКТИВНО - ПРОДОЛЖАЕМ ДОБАВЛЯТЬ ПОЛЬЗОВАТЕЛЕЙ if mes_user == 'НАЙТИ': # ИЩЕМ ЛОББИ lobby, i, first_id = connect.AddUserInLobbyFind( user_id, vk) print(lobby[1]) if lobby[1] == 1: timer = time.time() monopoly[i] = Monopoly(i, lobby[0], first_id, vk, timer) print('ДА') else: print('НЕТ') else: users_bot_class_dict = Lilly() text = users_bot_class_dict.update_screen(mes_user) vk_methods.write_msg(user_id, text, button="keyboard.json") else: if is_active[1] == 1: # КОД ОСНОВНОЙ ИГРЫ text = "Да начнется Монополия\n" button = "game.json" text = monopoly[i_user].update_screen(mes_user, user_id) button = monopoly[i_user].button print(button) if not text == False: vk_methods.write_msg(user_id, text, button) elif mes_user == 'ОТМЕНИТЬ ПОИСК': connect.cancelSearchUsers(user_id, is_active, name, vk) else: text = "Ожидайте подключения других игроков!" vk_methods.write_msg(user_id, text, button) print('Text:', mes_user) print()