aboutsummaryrefslogtreecommitdiff
path: root/challenge-024/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2023-05-04 09:02:23 +0100
committerGitHub <noreply@github.com>2023-05-04 09:02:23 +0100
commit6b200c68b4a2c0da08d591ddd1e19b81769d64a8 (patch)
tree7cfc71fb44b92d1c701ad2b095f05f049685c132 /challenge-024/paulo-custodio/python/ch-2.py
parent97f7c0542dc51b3fb7f36c0ecdf0a761084bfdc6 (diff)
parentba1f9c9bba63dc84941143530dfe11619386f90e (diff)
downloadperlweeklychallenge-club-6b200c68b4a2c0da08d591ddd1e19b81769d64a8.tar.gz
perlweeklychallenge-club-6b200c68b4a2c0da08d591ddd1e19b81769d64a8.tar.bz2
perlweeklychallenge-club-6b200c68b4a2c0da08d591ddd1e19b81769d64a8.zip
Merge pull request #8013 from pauloscustodio/master
Add solutions
Diffstat (limited to 'challenge-024/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-024/paulo-custodio/python/ch-2.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/challenge-024/paulo-custodio/python/ch-2.py b/challenge-024/paulo-custodio/python/ch-2.py
index 7b3aff407a..6f4ab47bb9 100644
--- a/challenge-024/paulo-custodio/python/ch-2.py
+++ b/challenge-024/paulo-custodio/python/ch-2.py
@@ -47,6 +47,9 @@ def create_database():
word_id INTEGER
);
''')
+ cur.execute('''
+ CREATE UNIQUE INDEX found_index ON found(document_id, word_id);
+ ''')
con.commit()
con.close()
@@ -94,7 +97,7 @@ def add_found(con, document_id, word_id):
def add_doc(file):
con = sqlite3.connect(DBFILE)
- title = os.path.basename(file)
+ title = re.sub(r"\.\w+$", "", os.path.basename(file))
document_id = get_document_id(con, title)
# read document