Created
December 17, 2015 17:21
-
-
Save vladyio/c4553b07453acd764693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
conn = sqlite3.connect('base.db') | |
c = conn.cursor() | |
while True: | |
a = input('\nДобавить запись: a \nУдалить: d INT\nВыход: b\n> ') | |
if a == 'a': | |
uid = int(input('Введите UserID: ')) # Интерфейс создания записи | |
nick = input('Введите Telegram Nick: ') | |
login = input('Введите Twitter Nick: ') | |
c.execute("""INSERT into users | |
VALUES ({}, '{}', '{}')""".format(uid, nick, login)) | |
elif a[0] == 'd': # Интерфейс удаления записи | |
c.execute("""DELETE FROM users WHERE uid={}""".format( | |
int(a.split()[1]))) | |
elif a == 'b': # Выход | |
break | |
conn.commit() | |
c.execute('SELECT * FROM users ORDER BY uid') # Cоздание выборки | |
for row in c: # Вывод всех строк БД | |
print(row) | |
c.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment