示例#1
0
def main():
    con = criar_conexao("localhost", "root", "", "youtube")

    insere_usuario(con, "Ola Mundo", "*****@*****.**", "olamundo")
    select_todos_usuarios(con)

    fechar_conexao(con)
def insert(query, parametros):
    connection = criar_conexao()
    cursor = connection.cursor()
    try:
        cursor.execute(query, parametros)
        connection.commit()
        return 'Inserido com sucesso!'
    except Error as e:
        print('Erro ao inserir!')
        connection.rollback()
        exit()
def consulta(query):
    connection = criar_conexao()
    cursor = connection.cursor()
    linhas = None
    try:
        cursor.execute(query)
        linhas = cursor.fetchall()
        _temporaria = {}
        resultado = {}
        for pos, linha in enumerate(linhas):
            for posicao, coluna in enumerate(cursor.description):
                _temporaria.update({coluna[0]: linha[posicao]})
            resultado.update({pos: _temporaria})
            _temporaria = {}

        return resultado
    except Error as e:
        print("ocorreu um erro")
        exit()
示例#4
0
def main():
    con = criar_conexao("adducis.ch3noq1jgsa1.us-east-2.rds.amazonaws.com",
                        "adducis", "654artesanais", "Usuarios")

    fechar_conexao
示例#5
0
import conexao
import consulta
import json

def listar_tarefas(connection):
    select_users = "SELECT * from teste1"
    users = consulta.query(connection, select_users)
    print (users)
    return TAREFAS

if __name__ == "__main__":
    conexao = conexao.criar_conexao()
    
    #listar_tarefas(conexao)