This is fine if we just want to use the database for ourselves.However, this leaves our database vulnerable to injection attacks.
However, if we’d try to append a PRIMARY KEY value that is not unique, a simple equivalent in SQLite.E.g., if we want to add a dataset to an existing database table that contains a mix between existing and new IDs for our PRIMARY KEY column.Another smaller project that uses in Python would be smilite, a module to retrieve and compare SMILE strings of chemical compounds from the free ZINC online database.If you are interested, you can check it out at: https://github.com/rasbt/smilite.Let’s have a look at some code: with a default value (here:’Hello World’), which will be inserted for every existing cell under this column and for every new row that we are going to add to the table if we don’t insert or update it with a different value.
Inserting and updating rows into an existing SQLite database table - next to sending queries - is probably the most common database operation.
A quick word on PRIMARY KEYS: In our example code above, we set our 1 column in the second table to PRIMARY KEY.
The advantage of a PRIMARY KEY index is a significant performance gain if we use the PRIMARY KEY column as query for accessing rows in the table. 1 PRIMARY KEY (single or multiple column(s)), and the values in this column MUST be unique!
Tip: A handy tool to visualize and access SQLite databases is the free Fire Fox SQLite Manager add-on.
Throughout this article, I will use this tool to provide screenshots of the database structures that we created below the corresponding code sections.
For example, if our database would be part of a web application, it would allow hackers to directly communicate with the database in order to bypass login and password verification and steal data.