T
T
Turkmen Time2020-08-21 13:14:31
Python
Turkmen Time, 2020-08-21 13:14:31

Is there something like ID in SQLITE PYTHON?

I made a program to create a database:

import sqlite3
from colorama import Fore

db = sqlite3.connect('Account.db')
sql = db.cursor()

global Twonum

def main():
    sql.execute("""CREATE TABLE IF NOT EXISTS Account (
        phone TEXT,
        pass TEXT,
        wallet TEXT,
        apiid TEXT,
        apihash TEXT
    )""")

    db.commit()

def main():
    global Phone
    Phone = input(Fore.YELLOW+'Ваш номер телефона:')
    Pass = input('Ваш пароль: ')
    Wallet = 'MyWallet'
    Apiid = 'xxxxxx'  
    Apihash = 'xxxxxx'   

    sql.execute(f"SELECT phone FROM Account WHERE phone = '{Phone}'")
    if sql.fetchone() is None:
        sql.execute(f"INSERT INTO Account VALUES (?,?,?,?,?)",(Phone, Pass, Wallet, Apiid, Apihash))
        db.commit()
        Correcting()
    else:
        print(Fore.RED+"Аккаунт с таким номером уже имеется")

def Correcting():
    Correct = input(Fore.LIGHTGREEN_EX+'Если все ОК то нажмите Enter, если по новой то напиши del: ')
    if Correct == '':
        print(Fore.LIGHTGREEN_EX+'Успешно добавлено!')
        #too_many_acc()
        for acc_count in sql.execute("SELECT Count(*) FROM Account"):
                print(Fore.LIGHTBLUE_EX,acc_count)
        for acc_data in sql.execute("SELECT phone, pass FROM Account"):
            print(Fore.BLUE,f"{acc_data}")
    elif Correct == 'del' or 'Del' or 'DEL' or 'dEL':
        sql.execute(f"DELETE FROM Account WHERE phone = '{Phone}'")
        print(Fore.LIGHTGREEN_EX+'Успешно удалено! Добавьте аккаунт заново:')
        main()


def too_many_acc():
    print(Fore.RED+'Добавление множества аккаунтов включено!')
    main()



__main__ = '__main__'
if __main__ == '__main__':
    main()

and so then, for example, I have about 50 accounts, for example, they all need to be sent to press a button, each account had its own number, it would be easy to do this, but I don’t know how to make these numbers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2020-08-21
@MrSel

https://www.sqlite.org/lang_createtable.html#rowid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question