def add_group(self, group_id, group_name, description, members_count): res = self.get_group_id(group_id) if not res: try: self.cursor.execute( "INSERT INTO groups VALUES(%s, %s, %s, %s);", ( group_id, api.clear(group_name), api.clear(description), members_count, )) self.cnct.commit() except Error as e: print(e) return False return True
def add_comment(self, group_id, topic_id, comment_id, user_id, is_member, text, emoji, likes, reply_comment, reply_id, date, aggression): id = self.get_group_topic_id(group_id, topic_id) res = self.get_comment_id(id, user_id, comment_id) if not res: try: self.cursor.execute( "INSERT INTO comments VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);", ( id, comment_id, user_id, is_member, api.clear(text), emoji, likes, reply_comment, reply_id, date, aggression, )) self.cnct.commit() if aggression == 0: self.total_count["nonaggressive"] += 1 elif aggression == 1: self.total_count["aggressive"] += 1 self.total_count["total"] += 1 print(self.total_count) except Error as e: print(e) return False return True
def add_comment(self, text): text = api.clear(text) q = "INSERT INTO comments VALUES({}, \"{}\")".format(0, text) try: self.cursor.execute(q) self.cnct.commit() except: pass
def add_user(self, user_id, user_name, gender, age, city, friends_count): res = self.get_user_id(user_id) if not res: try: self.cursor.execute( "INSERT INTO users VALUES(%s, %s, %s, %s, %s, %s);", (user_id, api.clear(user_name), gender, age, city, friends_count)) self.cnct.commit() except Error as e: print(e) return False return True
def add_topic(self, group_id, topic_id, topic_text, likes, reposts, total_ct, date): id = self.get_group_topic_id(group_id, topic_id) if not id: try: self.cursor.execute( "INSERT INTO topics VALUES(0, %s, %s, %s, %s, %s, %s, %s);", (group_id, topic_id, api.clear(topic_text), likes, reposts, total_ct, date)) self.cnct.commit() except Error as e: print(e) return False return True
def main(): """Shows basic usage of the Sheets API. Prints values from a sample spreadsheet. """ # The ID and range of a sample spreadsheet. spreadsheet_id = config['spreadsheet']['id'] service = api.service() conn = database.connection() cursor = conn.cursor() # Call the Sheets API spreadsheet = service.spreadsheets() for sheet in config['spreadsheet']['sheets']: query = config['spreadsheet']['sheets'][sheet]['query'] range = config['spreadsheet']['sheets'][sheet]['name'] + '!' + config[ 'spreadsheet']['sheets'][sheet]['range'] cursor.execute(query) cols = [desc[0] for desc in cursor.description] rows = cursor.fetchall() values = [cols] for row in rows: values.append(list(row)) update_range = range + str(len(values)) response_cleared = api.clear(spreadsheet=spreadsheet, id=spreadsheet_id, range=range) body = {'range': update_range, 'values': values} response_update = api.update(spreadsheet=spreadsheet, id=spreadsheet_id, range=update_range, body=body) if conn is not None: conn.close()
def main(): api.clear() api.banner() print(""" 1) IP 2) IP 2 3) CEP 4) CEP 2 5) CNPJ 6) Banco 7) COVID-19 8) Whois 11) Placa de veículos 12) DDD S) Sair """) main_input = input("Escolha uma opção: ") if main_input in "1": api.clear() api.ip() elif main_input in "2": api.clear() api.ip2() elif main_input in "3": api.clear() api.cep() elif main_input in "4": api.clear() api.cep2() elif main_input in "5": api.clear() api.cnpj() elif main_input in "6": api.clear() api.banks() elif main_input in "7": api.clear() api.covid19() elif main_input in "8": api.clear() api.whois() elif main_input in "11": api.clear() api.placa() elif main_input in "12": api.clear() api.ddd() elif main_input in "Ss": api.clear() else: api.clear() print("Opção invalida.")