コード例 #1
0
    def create_classification(self):

        sess = Database().session()

        sess.add(
            DBClassification(
                created_at=self.created_at,
                result=self.result,
            ))

        sess.commit()
        sess.close()
コード例 #2
0
print('Querying regeringen.se...')
remisser = Downloader.get_last_remisser(AMOUNT)

nb_of_remisser = len(remisser)
print(f'I-2 - Found {nb_of_remisser} remisser online.\n')

for index, online_remiss in enumerate(remisser, start=1):
    found = False
    for saved_remiss in saved_remisser:
        if saved_remiss.url == online_remiss.url:
            print(f'{index}/{nb_of_remisser} remiss(er) - '
                  f'Already saved (id {saved_remiss.id})')
            found = True

    if found:
        continue

    Database.add(online_remiss)
    Database.flush()

    documents = Downloader.get_documents(online_remiss)

    for doc in documents:
        Database.add(doc)

    Database.commit()
    print(f'{index}/{nb_of_remisser} remiss(er) saved - '
          f'{len(documents)} documents(s)')

Database.close()