How to properly handle such exceptions?

Please help with a simple question. How to properly handle such exceptions. In this case, create a database, but if it was previously created, you do not need to do nothing, not output. In this case, I do other things not found, but remembered that there is a thing pass and don't quite understand whether I will use it
import sqlite3 as sql

def connectorSQL():
 conn = sql.connect(R BD\links.sqlite')
 cursor = conn.cursor()
try:
 cursor.execute("create table Analysis (link text, counter integer, price integer)")
 print("Created table Analysis")
 except sql.OperationalError:
 pass
March 19th 20 at 08:51
1 answer
March 19th 20 at 08:53
Solution
In this case the right - not to lead to the emergence of exceptions: create table if not exists analysis ...
Not quite sure how it works in this case - Berry_Bechtelar commented on March 19th 20 at 08:56
@Berry_Bechtelar, the DBMS knows is in the database table or not, so can just ignore such a request and the error does not occur. - otto.Smitham commented on March 19th 20 at 08:59
@otto.Smitham, got it, thanks) - Berry_Bechtelar commented on March 19th 20 at 09:02

Find more questions by tags Python