Skip to content

Instantly share code, notes, and snippets.

@vladyio
Created December 17, 2015 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladyio/c4553b07453acd764693 to your computer and use it in GitHub Desktop.
Save vladyio/c4553b07453acd764693 to your computer and use it in GitHub Desktop.
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