
Ich arbeite gerade an einem Programm, welches auch einen 'table' erstellen soll.
Nach dem Tutorial auf http://sebastianraschka.com/Articles/20 ... orial.html habe ich meinen Code folgendermaßen gemacht:
Code: Alles auswählen
def table_create(self):
""" create the table """
# todo: output if create or failure
table = self.table_name_input.get()
one = self.language_one_input.get()
two = self.language_two_input.get()
conn = sqlite3.connect('./db/data.db')
cur = conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS {table} ({one}, {two}, priority)'.format(table=table, one=one, two=two))
Code: Alles auswählen
# 5) Check if a certain ID exists and print its column contents
c.execute("SELECT * FROM {tn} WHERE {idf}=?".\
format(tn=table_name, cn=column_2, idf=id_column), (123456,))
Code: Alles auswählen
sqlite3.OperationalError: near "=": syntax error
Sind "nur" die 'queries' wie ('Select * FROM ...) von 'injection' bedroht oder auch das Anlegen eines 'tables'? Wenn auch das erstellen eines 'tables', wie kann ich es dann sicher machen?