From ba90f7fd6f82b551d47f33b1a35413acfc6ea11f Mon Sep 17 00:00:00 2001 From: FilhoDoan Date: Tue, 28 Nov 2023 01:05:38 -0300 Subject: [PATCH 1/4] =?UTF-8?q?adicionando=20personagem=204=20opera=C3=A7?= =?UTF-8?q?=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/Banco/{database.py => Database.py} | 0 game/Banco/{local.py => Local.py} | 10 +-- game/Banco/{missao.py => Missao.py} | 2 +- game/Banco/{mundo.py => Mundo.py} | 6 +- game/Banco/Personagem.py | 65 ++++++++++++++++++ game/Banco/{regiao.py => Regiao.py} | 7 +- game/Banco/__init__.py | 11 +++ .../__pycache__/Database.cpython-310.pyc | Bin 0 -> 617 bytes game/Banco/__pycache__/Local.cpython-310.pyc | Bin 0 -> 2404 bytes game/Banco/__pycache__/Mundo.cpython-310.pyc | Bin 0 -> 2424 bytes .../__pycache__/Personagem.cpython-310.pyc | Bin 0 -> 2478 bytes game/Banco/__pycache__/Regiao.cpython-310.pyc | Bin 0 -> 2250 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 281 bytes game/Banco/__pycache__/local.cpython-310.pyc | Bin 0 -> 2411 bytes game/Banco/__pycache__/mundo.cpython-310.pyc | Bin 2383 -> 2434 bytes game/Banco/__pycache__/regiao.cpython-310.pyc | Bin 2255 -> 2260 bytes game/main.py | 25 +++++++ .../controller.py => model/__init__.py} | 0 game/model/__pycache__/Mundo.cpython-310.pyc | Bin 538 -> 0 bytes game/model/__pycache__/mundo.cpython-310.pyc | Bin 538 -> 0 bytes game/model/mundo.py | 5 -- game/view/view.py | 0 22 files changed, 115 insertions(+), 16 deletions(-) rename game/Banco/{database.py => Database.py} (100%) rename game/Banco/{local.py => Local.py} (95%) rename game/Banco/{missao.py => Missao.py} (98%) rename game/Banco/{mundo.py => Mundo.py} (96%) create mode 100644 game/Banco/Personagem.py rename game/Banco/{regiao.py => Regiao.py} (97%) create mode 100644 game/Banco/__init__.py create mode 100644 game/Banco/__pycache__/Database.cpython-310.pyc create mode 100644 game/Banco/__pycache__/Local.cpython-310.pyc create mode 100644 game/Banco/__pycache__/Mundo.cpython-310.pyc create mode 100644 game/Banco/__pycache__/Personagem.cpython-310.pyc create mode 100644 game/Banco/__pycache__/Regiao.cpython-310.pyc create mode 100644 game/Banco/__pycache__/__init__.cpython-310.pyc create mode 100644 game/Banco/__pycache__/local.cpython-310.pyc create mode 100644 game/main.py rename game/{controller/controller.py => model/__init__.py} (100%) delete mode 100644 game/model/__pycache__/Mundo.cpython-310.pyc delete mode 100644 game/model/__pycache__/mundo.cpython-310.pyc delete mode 100644 game/model/mundo.py delete mode 100644 game/view/view.py diff --git a/game/Banco/database.py b/game/Banco/Database.py similarity index 100% rename from game/Banco/database.py rename to game/Banco/Database.py diff --git a/game/Banco/local.py b/game/Banco/Local.py similarity index 95% rename from game/Banco/local.py rename to game/Banco/Local.py index a75c058..cbff9de 100644 --- a/game/Banco/local.py +++ b/game/Banco/Local.py @@ -1,8 +1,10 @@ import psycopg2 -from database import Database -from mundo import mundo -from regiao import regiao -class local : +from .Database import Database +from .Mundo import Mundo +from .Regiao import Regiao + + +class Local : def __init__(self): self.db = Database() pass diff --git a/game/Banco/missao.py b/game/Banco/Missao.py similarity index 98% rename from game/Banco/missao.py rename to game/Banco/Missao.py index 3a15dc2..dca8ea3 100644 --- a/game/Banco/missao.py +++ b/game/Banco/Missao.py @@ -1,5 +1,5 @@ import psycopg2 -from database import Database +from .Database import Database class Missao: def __init__(self): diff --git a/game/Banco/mundo.py b/game/Banco/Mundo.py similarity index 96% rename from game/Banco/mundo.py rename to game/Banco/Mundo.py index f5f5aa2..b2766c7 100644 --- a/game/Banco/mundo.py +++ b/game/Banco/Mundo.py @@ -1,8 +1,8 @@ import psycopg2 -from database import Database +from .Database import Database -class mundo: +class Mundo: ## construtor com argumento def __init__(self, nome, mundoDestino): self.nome = nome @@ -59,9 +59,7 @@ def consultarMundoNome(self,nome): consulta = cursor.fetchall() for x in consulta: print(x) - return x except psycopg2.Error as e: print("Erro ao executar a consulta:", e) finally: cursor.close() - diff --git a/game/Banco/Personagem.py b/game/Banco/Personagem.py new file mode 100644 index 0000000..985606d --- /dev/null +++ b/game/Banco/Personagem.py @@ -0,0 +1,65 @@ +import psycopg2 +from .Database import Database + + +class Personagem: + def __init__(self): + self.db = Database() + pass + + def criarPersonagem(self, IDpersonagem,ATC:bool): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"""insert into personagem values({IDpersonagem},{ATC});""") + insercaoPersonagem = conexao.commit() + return print("Personagem criado com sucesso") + except psycopg2.Error as e: + print("Erro ao inserir personagem", e) + finally: + cursor.close() + + def consultarPersonagem(self): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"""Select * from personagem;""") + consultarPersonagem = cursor.fetchall() + for x in consultarPersonagem: + print(x) + + except psycopg2.Error as e: + print("") + finally: + cursor.close() + + def consultarPersonagemID(self, IDpersonagem:int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"""Select * from personagem where IDpersonagem = {IDpersonagem};""") + consultarPersonagemID = cursor.fetchall() + if(consultarPersonagemID == []): + print('Não possui esse personagem') + else: + for x in consultarPersonagemID: + print(x) + except psycopg2.Error as e : + print("Erro ao consultar personagem por ID:", e ) + finally: + cursor.close() + + def deletarPersonagem(self, IDpersonagem:int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + query = cursor.execute(f"""delete from personagem where IDpersonagem = {IDpersonagem};""") + conexao.commit() + query_exec = query + except psycopg2.Error as e: + print("Erro ao deletar em Mundo", e) + finally: + cursor.close() + + + \ No newline at end of file diff --git a/game/Banco/regiao.py b/game/Banco/Regiao.py similarity index 97% rename from game/Banco/regiao.py rename to game/Banco/Regiao.py index 7e55d8e..8aaf628 100644 --- a/game/Banco/regiao.py +++ b/game/Banco/Regiao.py @@ -1,6 +1,9 @@ import psycopg2 -from database import Database -class regiao: +from .Database import Database + + + +class Regiao: def __init__(self): self.db = Database() diff --git a/game/Banco/__init__.py b/game/Banco/__init__.py new file mode 100644 index 0000000..888839a --- /dev/null +++ b/game/Banco/__init__.py @@ -0,0 +1,11 @@ +from .Mundo import * +from .Regiao import * +from .Local import * +from .Personagem import * + + + + + + + diff --git a/game/Banco/__pycache__/Database.cpython-310.pyc b/game/Banco/__pycache__/Database.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..52fb808582f3f49ef855650e3338fb24105f69fd GIT binary patch literal 617 zcmYjPy-ve05Oy2`;r~Yrhy~UTB@kAGfEK}224Lx8nVcy_Aue{xpI8uGc@Un1xA4lu z127;laF@2I7u}aT`|iH;*=BZjilMl*3;l!tPjW^jL}w4xts($}AY)B-#DGKCV-UXb zW&pt{tB5b$XN{C_R5&_&sBRfSGmK_U4gv5UYlaX~rjP2XP#4PSG{B&tkUfrCLv7liiY$J{6Z^MAhi>}ia!2(XSYLTKtb5MmA`&Qs!7tN;e`m&olz_v_@A)*YAikVlzRxQsI_fOlgl~P)nB5e6-Ui+NBE|ir;ewRX(kA7HfCUjy#7f9=Jd_jzACVsx}Y;Ltzk zeA*`DH@vAHI^4VmXLJ(`Ba8;5OPI#=fc9yZQuK{L>uX(2`DUQ^^{!6I2ZULyc1T$5 zKln446oQrTq zO)xPzASrR-XCQ=jTAIWRGL5Z5l19XXwMRtOVd#%_FzpS|=WQmuaIF_?i1zV!l6wy0 z&X*FN5JzqYfx9ReZ-3Rfv-sK4-R1TjFZ4z9R(t-<`M2lhXFn9un`M0V_I)141L?Kb zJ=jt$YO8$bwsteyb$ekic3nV4B22hRld*idoXU*2w*?q_h4kCQi2 zvPm}So|Re;wIi}uOKT5xMpOC|AWb!}da8ppQbUcHV9f_3M}Qn642ZB}DD(kcAu9x8 zts_FARtAY{oA&M!C3|&Bk`Y)_OX~;F94q8&XrR6Nemykv>o(o4#A2n(eYT-lI?1Jv z!idY*>4mXy0%Ydg_ksbBUQe{^Gl@O}Mw__~PHQ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c0jLdkZGn&!g0aT`e)t{QDfC|P97&l{+ z87K5Uxlh2;IwcgcVvxA9Zy&Ex(z7T@r@_a}tP_ob*Y^OvXFaw;vuF?L;m};nX+O>( zz;C73olY2W8AB5bM=CzfBQHpJ^zLG+FTRhav6@_m_2Xt={2_`N9p*W{=sHp2^C%MO z!j_c6@%p3E;a%seBxK_Glr&*-Uhzf9k35lEej+0w^9n!WeiCzdA-dg8oSO#{R*{>2 zAR?aI2hp)F4t7^^6GO{JMOqlg2!VKRb}_b`hBp#VO@2Y`!}mmiB&S>*lET>NQCA)v zSvVk>=qeb4+VER|yGpCZ#ee3h{iF7;M(4Hka^bo>GSNr&{R>w#VEi*Yq+g^rO2)ub zF-Fz{#!q!cS5tHiAg7mf^)b3116{MEYh)nU0bTR4spvvm(ktWrLf3L&>zB4 zNACd*Igg_#h+!UOz#wV`gIKyk}H|1kc$@wBUStdp+eP_FuaYQlpwpxie`zdVEfC>t za2`rIo_nlB=Td%ka>_A8t6}5kDTL3K>*iJ0?FyCz*sr401*VjXf}K`XN~^= DtjPVA literal 0 HcmV?d00001 diff --git a/game/Banco/__pycache__/__init__.cpython-310.pyc b/game/Banco/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..587b22657bc62df32d16e78c5e9f83fe8b488d12 GIT binary patch literal 281 zcmYk0u}%Xq42F{{g{Y$M(1GQUu7P7kh_)axK#ORZBh#4cp?A>Ch$wPtFhX{MTu#ul9uJnp3)Rw?MmTpD*^DQ6@ zEDja{9-y6!oHG-$sPCua$?W2CuE*e)R3Gd7C_fqI*%bxIEM}t@^y?;oE`U#NOxl>z bmuq8&&#zIPR%9E8XYI?iVo^d#CHLhoBh*L; literal 0 HcmV?d00001 diff --git a/game/Banco/__pycache__/local.cpython-310.pyc b/game/Banco/__pycache__/local.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c569cbae6667b5c208704f338c865e2ca9087e0f GIT binary patch literal 2411 zcma);&u`pB6vt=$YrU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310.pyc b/game/Banco/__pycache__/mundo.cpython-310.pyc index 20d4abb00ffe378e791a1c2a435cc53e2ee16b68..d041c9e5a03afa35d43eeb2f645ea756b00a4c76 100644 GIT binary patch delta 752 zcmZuvO-md>5bf%ok6yP&W&DW7Xx39QCgu_dEQ+VVo+5$=LA;FH6N1d{K+i5F5;d6I zMdp@Ma`YDP7X(k9a?bn%|AeNh#fj+7Ft4Zky;oh`Re!>xu^reUi(9wrY0nIj9{E#0^xSM%2UdA*3J8A zFD~KZgN=#{Z%2Md-(G94Q7rk(YJ+vB9M5@iy}+X?upqA9PV>j^s}X?q3qFmErB-jJ?R!tn)m1 zgGAmya6sZ4S{wrBdX!Is{KBvKm2&x2VdUGxI?Bux!3;rzV4mQAG3=jh0|yCen4Geg zOmZ&pOx)UvdqR$ zuJC2igQqZswkI&&<7ZGyY+jzG+60eBN?JH`_8-mJlNzu8;!3 zD2JHB)H}q~TT)OMK0&tj1>}6oc{Mc|a9u(haVpmFOGcGHHsM5m0>X+m<_2(R43aSq5qO+r|;!-=pW02^n_$V0DvRf~mI-bYJAZr1P158Nh+VwO6E&0`2!>c<1 zzW8S(-t}|(D0R*K=Car`w#lU?j?_uKEAEYyp)qu&U+dyQO^HteT9QhorE({sH5 diff --git a/game/Banco/__pycache__/regiao.cpython-310.pyc b/game/Banco/__pycache__/regiao.cpython-310.pyc index 548effebc4649c2f32505149e78bc27031b94575..d1119ac575e867f51c620b6b2d1bf0a5a78fd1a7 100644 GIT binary patch delta 548 zcmZvZy-ve06oq~BYal74El>e!8A%6Lqzb`;)QtfohQgB8E>z@4a@v^z7RD+IufTv9 zD)9=82#LvW(6_)hg;t;eB~-;=0R3J@F&suVc5_)R-PZq;)hPZNdy@ zJ`iT!YaN}zIq|J2HlI#GaeVbu)zw>Stm}g`QXcl7iLfUWUI5JOO>4I-)QvcaxHO|t z%o4GpD#F2XX%MGe^n&D!Uk`#r0v9%lIq2j-zkn8=&9?-O5f#M3?lKW%ve6@LyN} delta 508 zcmca2cwUevVVq|beK<+J$wA7O1jKrLrB0i8TKZp6YD`z$VXVFAic$fe2}kaqQUKUL*^Wmje;#&YrxF zy;+X~BqIhQBtZmNwLFN02p@H_p-cn)S> zz$?$d&N(fjob-M6{d{+4t0-z9u!GMV@e1dcbJooVrw1@ipfkh~#|yxlmm=;BQS6T( z{?7vNdH}NnBv6VuNptvB{$?@Rw1{ct(+sM5J*o9GAA9d@h$ diff --git a/game/model/__pycache__/mundo.cpython-310.pyc b/game/model/__pycache__/mundo.cpython-310.pyc deleted file mode 100644 index 3d7f30a9e58928f99fcbdf87cf9934277a47dc68..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 538 zcmY*VyH3L}6t(jxRYfG!ff04h&>G5$pbrpCVJHYGi)CuJ4N7gW8zfK{pg+TR@B!>z z`382blOoEM&avjBIjkU%NsDD^lNKKFz_3AoRLRgeZegzTCP=Y{0T22#z1jY@@bVHTNGW7qpv+}{HX z0cHniiI<3?CAz~Hrh-~Hi9PK?w2O^>8yJyK{w(iEhv4|00+AWCBU~{#$?};ZA1_+4 z78k86&2E{q^z)n!6&K_>84NE^&qidxfMNT*U&D-){m;5$7P-ywuycKR`7Q> diff --git a/game/model/mundo.py b/game/model/mundo.py deleted file mode 100644 index 7bab633..0000000 --- a/game/model/mundo.py +++ /dev/null @@ -1,5 +0,0 @@ -class mundo: - def __init_(self, nome: str, mundo_destino:str ): - self.nome = nome - self.mundo_destino - \ No newline at end of file diff --git a/game/view/view.py b/game/view/view.py deleted file mode 100644 index e69de29..0000000 From 299d1dcd55a3653839f0e399c9be6f09cf7d8cde Mon Sep 17 00:00:00 2001 From: Dyetrix Date: Tue, 28 Nov 2023 13:36:23 -0300 Subject: [PATCH 2/4] Criando classe Instacia e adicionando 5 operacoes entre o banco --- game/Banco/Instancia.py | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 game/Banco/Instancia.py diff --git a/game/Banco/Instancia.py b/game/Banco/Instancia.py new file mode 100644 index 0000000..1578f96 --- /dev/null +++ b/game/Banco/Instancia.py @@ -0,0 +1,114 @@ +import psycopg2 +from typing import Optional +from Database import Database + +class Instancia: + + def __init__(self, personagem: int, numero: int, vida: int, local: int, idPersonagem: int): + self.personagem = personagem + self.numero = numero + self.vida = vida + self.local = local + self.idPersonagem = idPersonagem + pass + + def __init__(self): + self.db = Database() + pass + + def inserirInstancia(self, personagem: int, numero: int, vida: int, local: int, idPersonagem: Optional[int]): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + + # Ussando a formatação %s porque assim o psycop trata a tipagem e permite argumento None, pra quando + # algo precisar ser nulo + ## i.inserirInstancia(3, 3, 37, 1, None) -> exemplo do None + cursor.execute("INSERT INTO instancia VALUES (%s, %s, %s, %s, %s);", (personagem, numero, vida, local, idPersonagem)) + insercaoInstancia = conexao.commit() + return print("Instancia criada com sucesso!\n") + + except psycopg2.IntegrityError as e: + print("Não foi possível inserir instancia na tabela: ", e) + + finally: + cursor.close() + + def deletarInstancia(self, personagem: int, numero: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"DELETE FROM instancia WHERE personagem = '{personagem}' AND numero = '{numero}';") + delecaoInstacia = conexao.commit() + return print("Instacia deletada com sucesso") + + except psycopg2.Error as e: + print("Erro ao deletar em instancia", e) + + finally: + cursor.close() + + def consultarInstancia(self): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM instancia;") + consulta = cursor.fetchall() + if not consulta: + print("Nao foi possivel ver instancias") + else: + for x in consulta: + print(x) + return x + + except psycopg2.Error as e: + print("Erro ao executar a consulta:", e) + + finally: + cursor.close() + + def consultarInstanciaPersonagem(self, personagem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM instancia WHERE personagem = '{personagem}';") + consulta = cursor.fetchall() + + if not consulta: + print("Não há nenhuma instancia com essas caracteristicas\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.Error as e: + print("Não foi possivel fazer essa consulta") + + finally: + cursor.close() + + def consultarInstanciaEspecifica(self, personagem: int, numero: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM instancia WHERE personagem = '{personagem}' AND numero = '{numero}';") + consulta = cursor.fetchall() + + if not consulta: + print("Não há nenhuma instancia com essas caracteristicas\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.Error as e: + print("Não foi possivel fazer essa consulta") + + finally: + cursor.close() + +## i = Instancia() +## i.consultarInstancia() + + + From 60464311768e8908ac692fdeaa7d1a2a9ef53eb4 Mon Sep 17 00:00:00 2001 From: Dyetrix Date: Tue, 28 Nov 2023 15:15:52 -0300 Subject: [PATCH 3/4] =?UTF-8?q?Criando=20classe=20FazMissao=20e=206=20oper?= =?UTF-8?q?a=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/Banco/FazMissao.py | 120 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 game/Banco/FazMissao.py diff --git a/game/Banco/FazMissao.py b/game/Banco/FazMissao.py new file mode 100644 index 0000000..73ad8d3 --- /dev/null +++ b/game/Banco/FazMissao.py @@ -0,0 +1,120 @@ +import psycopg2 +from Database import Database + +class FazMissao: + + def __init__(self, personagem: int, nomeMissao: str, status: bool): + self.personagem = personagem + self.nomeMissao = nomeMissao + self.status = status + pass + + def __init__(self): + self.db = Database() + pass + + def inserirFazMissao(self, personagem: int, nomeMissao: str, status: bool): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + + cursor.execute("INSERT INTO fazmissao VALUES(%s, %s, %s);", (personagem, nomeMissao, status)) + insercaoFazMissao = conexao.commit() + return print("Missao inserida com sucesso!\n") + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def deletarFazMissao(self, personagem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor + + cursor.execute(f"DELETE FROM fazmissao WHERE personagem = '{personagem}';") + delecaoFazMissao = cursor.commit() + return print("Missao deletada com sucesso!\n") + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def deletarFazMissaoEspecifica(self, personagem: int, nomeMissao: str): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + + cursor.execute(f"DELETE FROM fazmissao WHERE personagem = '{personagem}' AND nomemissao = '{nomeMissao}';") + delecaoFazMissao = conexao.commit() + return print("Missao deletada com sucesso!\n") + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def consultarFazMissao(self): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM fazmissao;") + consulta = cursor.fetchall() + + if not consulta: + print("Não foi possivel acessar a tabela\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def consultarFazMissaoPersonagem(self, personagem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM fazmissao WHERE personagem = '{personagem}';") + consulta = cursor.fetchall() + + if not consulta: + print("Não foi encontrada nenhuma missao desse personagem\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def consultarFazMissaoNome(self, nome: str): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM fazmissao WHERE nomemissao = '{nome}';") + consulta = cursor.fetchall() + + if not consulta: + print("Não foi encontrada nenhuma missao com esse nome\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + From 0989e275ee221cbd662d12c25e0bb3568d741b2e Mon Sep 17 00:00:00 2001 From: Dyetrix Date: Tue, 28 Nov 2023 17:22:51 -0300 Subject: [PATCH 4/4] =?UTF-8?q?Adicionando=20classe=20item=20e=20as=203=20?= =?UTF-8?q?opera=C3=A7=C3=B5es=20b=C3=A1sicas=20do=20banco?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/Banco/FazMissao.py | 2 +- game/Banco/Item.py | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 game/Banco/Item.py diff --git a/game/Banco/FazMissao.py b/game/Banco/FazMissao.py index 73ad8d3..e2cea42 100644 --- a/game/Banco/FazMissao.py +++ b/game/Banco/FazMissao.py @@ -31,7 +31,7 @@ def inserirFazMissao(self, personagem: int, nomeMissao: str, status: bool): def deletarFazMissao(self, personagem: int): try: conexao = self.db.conexao - cursor = conexao.cursor + cursor = conexao.cursor() cursor.execute(f"DELETE FROM fazmissao WHERE personagem = '{personagem}';") delecaoFazMissao = cursor.commit() diff --git a/game/Banco/Item.py b/game/Banco/Item.py new file mode 100644 index 0000000..1054f99 --- /dev/null +++ b/game/Banco/Item.py @@ -0,0 +1,84 @@ +import psycopg2 +from Database import Database + +class Item: + + def __init__(self, idItem: int, atcItem: int): + self.idItem = idItem + self.atcItem = atcItem + pass + + def __init__(self): + self.db = Database() + pass + + def inserirItem(self, idItem: int, atcItem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + + cursor.execute("INSERT INTO item VALUES(%s, %s);", (idItem, atcItem)) + insercaoFazMissao = conexao.commit() + return print("Item inserido com sucesso!\n") + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a insercao. Erro: {e}\n") + + finally: + cursor.close() + + def deletarItem(self, idItem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + + cursor.execute(f"DELETE FROM item WHERE iditem = '{idItem}';") + delecaoFazMissao = cursor.commit() + return print("Item deletado com sucesso!\n") + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a delecao. Erro: {e}\n") + + finally: + cursor.close() + + def consultarItemId(self, idItem: int): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM item WHERE iditem = '{idItem}';") + consulta = cursor.fetchall() + + if not consulta: + print("Não foi há itens cadastrados\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() + + def consultarItem(self): + try: + conexao = self.db.conexao + cursor = conexao.cursor() + cursor.execute(f"SELECT * FROM item;") + consulta = cursor.fetchall() + + if not consulta: + print("Não foi há itens cadastrados\n") + else: + for i in consulta: + print(i) + return i + + except psycopg2.IntegrityError as e: + print(f"Encontramos problemas ao fazer a consulta. Erro: {e}\n") + + finally: + cursor.close() +