예제 #1
0
def send_report():
    from_time = settings.from_time
    session = Session()
    res = '累计打卡(%s起)\n' % from_time
    for row in session.query(Sharing.name, func.count().label('credit'))\
                               .filter(Sharing.title.isnot(None) & Sharing.thinking.isnot(None))\
                               .group_by(Sharing.name)\
                               .order_by(desc('credit')):
        res += '    %s: %.1f\n' % (row.name, row.credit * 0.2)
    with engine.connect() as con:
        today_daka = pd.read_sql_query(
            "select * from sharing where date(time) >= current_date order by id desc",
            con)
        today_daka.rename(inplace=True,
                          columns={
                              'id': '序号',
                              'name': '姓名',
                              'title': '标题',
                              'thinking': '感想',
                              'time': '时间'
                          })
        now = datetime.datetime.now()
        if not os.path.isdir('daka'):
            os.mkdir('daka')
        filename = "daka/%s(00.00.00-%s).xlsx" % (
            now.date().strftime('%Y-%m-%d'), now.time().strftime('%H.%M.%S'))
        to_excel(today_daka, filename)

    for group in bot.groups().search(settings.notice_group_name):
        group.send(res)
        group.send_file(filename)
예제 #2
0
def atualiza_cliente():
    username = input('Digite o nome atual do cliente: ')
    conn = engine.connect()
    atualizar = update(user_table).where(user_table.c.nome == username)
    novo_nome = input('Insira o novo nome: ')
    atualizar = atualizar.values (nome= novo_nome)
    resultado = conn.execute(atualizar)
    print(resultado.rowcount)
예제 #3
0
def insere_cliente():
    cliente_name = input('Novo cliente: ')
    cliente_endereco = input('Endereco do cliente: ')
    conn = engine.connect()
    insercao = user_table.insert()
    novo_cliente = insercao.values(nome=cliente_name,
                                   endereco=cliente_endereco)
    conn.execute(novo_cliente)
def truncate_db():

    con = engine.connect()
    trans = con.begin()
    for table in metadata.sorted_tables:
        con.execute(table.delete())
    trans.commit()
    print('Cleaned')
예제 #5
0
#!/usr/bin/python3

from core import user_table, engine

con = engine.connect()
ins = user_table.insert()

# new = ins.values(idade=24, nome='Daniel', senha='teste123')
# con.execute(new)

con.execute(ins, [
    {'nome': 'João', 'idade':38, 'senha': 'senha123'},
    {'nome': 'Maria', 'idade':25, 'senha': '123@mudar'}
])
def truncate_db():
    con = engine.connect()
    con.execute('TRUNCATE TABLE gitlab RESTART IDENTITY')
    print('Cleaned')
예제 #7
0
from sqlalchemy import update
from core import user_table, engine

conexao = engine.connect()

antigo_nome = input("Digite o antigo nome: ")
novo_nome = input("Digite o novo nome: ")
atualizar = update(user_table).where(user_table.c.nome == antigo_nome)
atualizar = atualizar.values(nome=novo_nome)
resultado = conexao.execute(atualizar)
print(resultado.rowcount)

예제 #8
0
def delete_cliente():
    nome_cliente = input('usuario a ser excluido: ')
    conn = engine.connect()
    dell = delete(user_table).where(user_table.c.nome == nome_cliente)
    resultado = conn.execute(dell)
    print(resultado.rowcount)