|
| 1 | +import csv |
| 2 | +import shutil |
| 3 | +import pyodbc |
| 4 | +import logging |
| 5 | +from andes_migrate.biometrie_petoncle import BiometriePetoncle |
| 6 | + |
| 7 | +from andes_migrate.capture_mollusque import CaptureMollusque |
| 8 | +from andes_migrate.oracle_helper import OracleHelper |
| 9 | +from andes_migrate.projet_mollusque import ProjetMollusque |
| 10 | +from andes_migrate.trait_mollusque import TraitMollusque |
| 11 | +from andes_migrate.engin_mollusque import EnginMollusque |
| 12 | +from andes_migrate.freq_long_mollusque import FreqLongMollusque |
| 13 | +from andes_migrate.andes_helper import AndesHelper |
| 14 | + |
| 15 | + |
| 16 | +logging.basicConfig(level=logging.ERROR) |
| 17 | + |
| 18 | + |
| 19 | +andes_db = AndesHelper() |
| 20 | +access_file = 'andes_migrate/ref_data/access_template.mdb' |
| 21 | +ref = OracleHelper(access_file=access_file) |
| 22 | + |
| 23 | + |
| 24 | +# INPUT VALUES |
| 25 | +no_notification = "IML-2023-011" |
| 26 | +zone = "20" |
| 27 | +espece = "pétoncle" |
| 28 | +SEQ_peche = 151 |
| 29 | + |
| 30 | +output_fname = f'./{no_notification}.mdb' |
| 31 | +shutil.copyfile('andes_migrate/ref_data/access_template.mdb', output_fname) |
| 32 | +con = pyodbc.connect( |
| 33 | + f"Driver={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={output_fname};" |
| 34 | +) |
| 35 | +output_cur = con.cursor() |
| 36 | + |
| 37 | + |
| 38 | +# proj = ProjetMollusque(andes_db, output_cur, ref=ref) |
| 39 | +# proj.init_input(zone="20", no_releve=34, no_notif=no_notification, espece="pétoncle") |
| 40 | +proj = ProjetMollusque(andes_db, output_cur, ref=ref, zone=zone, no_notif=no_notification, espece=espece) |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +for p in proj: |
| 45 | + print(f"Projet: ", p) |
| 46 | + |
| 47 | + with open('biometrie.csv','w') as fp: |
| 48 | + writer = csv.DictWriter(fp, lineterminator="\n", fieldnames=["id_specimen", |
| 49 | + "secteur", |
| 50 | + "trait", |
| 51 | + "no", |
| 52 | + "taille", |
| 53 | + "poids_vif", |
| 54 | + "poids_muscle", |
| 55 | + "poids_gonade", |
| 56 | + "poids_visceres", |
| 57 | + "poids_gonade", |
| 58 | + "sexe", |
| 59 | + "comment"]) |
| 60 | + writer.writeheader() |
| 61 | + collection_name='Conserver le spécimen (Biométrie Ouest)' |
| 62 | + biometrie = BiometriePetoncle(andes_db, proj, collection_name, output_cur) |
| 63 | + for b in biometrie: |
| 64 | + print(b) |
| 65 | + writer.writerow(b) |
| 66 | + |
| 67 | + collection_name='Conserver le spécimen (Biométrie Centre)' |
| 68 | + biometrie = BiometriePetoncle(andes_db, proj, collection_name, output_cur) |
| 69 | + for b in biometrie: |
| 70 | + print(b) |
| 71 | + writer.writerow(b) |
| 72 | + |
| 73 | + exit() |
| 74 | +# trait = TraitMollusque(andes_db, proj, output_cur) |
| 75 | +# for t in trait: |
| 76 | +# no_moll = 1 |
| 77 | +# print(f"Trait: ", t) |
| 78 | +# engin = EnginMollusque(trait, output_cur) |
| 79 | +# for e in engin: |
| 80 | +# # print(f"Engin: ", e) |
| 81 | +# capture = CaptureMollusque(engin, output_cur) |
| 82 | +# for c in capture: |
| 83 | +# # print(f"Capture: ", c) |
| 84 | + |
| 85 | +# freq = FreqLongMollusque(capture, output_cur, no_moll_init=no_moll) |
| 86 | +# for f in freq: |
| 87 | +# # print(f"FreqLong: ", f) |
| 88 | +# # if (c['COD_ESP_GEN'] == 48 or c['COD_ESP_GEN'] == 50) : |
| 89 | +# no_moll += 1 |
| 90 | + |
| 91 | + |
| 92 | +# monolithic commit if no errors are found |
| 93 | +# output_cur.commit() |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +# for i in range(12): |
| 100 | +# trait._increment_row() |
| 101 | +# print("trait: ", trait.get_ident_no_trait()) |
| 102 | + |
| 103 | +# statement = trait.get_insert_statement() |
| 104 | +# cur.execute(statement) |
| 105 | +# cur.commit() |
| 106 | + |
| 107 | + |
| 108 | +# statement = engin.get_insert_statement() |
| 109 | +# cur.execute(statement) |
| 110 | +# cur.commit() |
| 111 | + |
| 112 | +# capture.populate_data() |
| 113 | +# statement = capture.get_insert_statement() |
| 114 | +# cur.execute(statement) |
| 115 | +# cur.commit() |
| 116 | + |
| 117 | +# freq_long = FreqLongMollusque(capture) |
| 118 | +# print("iterating...") |
| 119 | +# for i in FreqLongMollusque(capture, output_cur): |
| 120 | +# print(i) |
| 121 | +# # statement = i.get_insert_statement() |
| 122 | +# # cur.execute(statement) |
| 123 | +# # cur.commit() |
0 commit comments