This repository has been archived by the owner on Sep 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert.py
39 lines (33 loc) · 1.48 KB
/
insert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sqlite3 as sq
import random as ra
connection = sq.connect('fragen.dat')
baseCursor=connection.cursor()
#baseCursor.execute(""" CREATE TABLE fragen(fragennummer SMALLINT PRIMARY KEY,semester SMALLINT, thema TEXT NOT NULL,frage TEXT NOT NULL, fragenloesung TEXT NOT NULL)""")
#baseCursor.execute("""INSERT INTO fragen VALUES(1,3, 'l',"Wodurch zeichnen sich virtuelle Verrückungen aus", "1. Instantant, 2. Berücksichtigen die ZWangsbedingungen, 3. infinitesimal")""")
#baseCursor.execute("""INSERT INTO fragen VALUES(2,3,'h',"Wie kommt man von Lagrange zu Hamilton ?", "Legendre-Tafo")""")
#baseCursor.execute("""INSERT INTO fragen VALUES(3,3,'k',"Wo hat man ein permanentes äußeres Drehmoment?", "praezession")""")
#baseCursor.execute(""" UPDATE fragen SET thema="wo" WHERE frage ="Was besagt das Babinetsche Prinzip?" """)
#connection.commit()
#baseCursor.execute(""" SELECT * FROM fragen""")
#fragen=baseCursor.fetchall()
#print(fragen)
stopper=''
baseCursor.execute(""" SELECT max(fragennummer) FROM fragen""")
startzahl=baseCursor.fetchall()[0][0]
while stopper != 'x':
startzahl+=1
print('Frage ?')
frage=input()
print('Lösung?')
loesung=input()
print('Semester?')
semester=input()
print('thema')
thema=input()
baseCursor.execute("""INSERT INTO fragen VALUES({},{},"{}","{}", "{}")""".format(startzahl,int(semester),thema,frage,loesung))
connection.commit()
stopper=input()
#print(letzte_element)
#print(test)
baseCursor.close()
connection.close()