|  | #!/usr/bin/env python3 | 
        
          |  | import sqlite3 | 
        
          |  | import random | 
        
          |  | from shutil import copyfile | 
        
          |  | import argparse | 
        
          |  | import pathlib | 
        
          |  |  | 
        
          |  |  | 
        
          |  | def main(input_gpkg, output_gpkg, table_name, geom_name, attributes): | 
        
          |  | copyfile(input_gpkg, output_gpkg) | 
        
          |  | src_con = sqlite3.connect(input_gpkg) | 
        
          |  | cur = src_con.cursor() | 
        
          |  | dest_con = sqlite3.connect(output_gpkg) | 
        
          |  | dest_cur = dest_con.cursor() | 
        
          |  | dest_con.enable_load_extension(True) | 
        
          |  | attributes_string = ",".join(attributes) | 
        
          |  | dest_con.execute("SELECT load_extension('mod_spatialite')") | 
        
          |  | count = 0 | 
        
          |  | for row in cur.execute(f"SELECT hex({geom_name}),{attributes_string} FROM {table_name}"): | 
        
          |  | random_number = random.randint(1, 10) | 
        
          |  | for i in range(random_number): | 
        
          |  | attributes_value_string = "" | 
        
          |  | for i in range(len(attributes)): | 
        
          |  | attributes_value_string += f"{row[i+1]}," | 
        
          |  | attributes_value_string = attributes_value_string[:-1] | 
        
          |  | insert_statement = f"INSERT INTO {table_name} ({geom_name},{attributes_string}) VALUES (X'{row[0]}',{attributes_value_string})" | 
        
          |  | dest_cur.execute(insert_statement) | 
        
          |  | count += 1 | 
        
          |  | dest_con.commit() | 
        
          |  | dest_con.close() | 
        
          |  | print(f"total number of duplicated features: {count}") | 
        
          |  |  | 
        
          |  |  | 
        
          |  | if __name__ == "__main__": | 
        
          |  | parser = argparse.ArgumentParser() | 
        
          |  | parser.add_argument('input_gpkg', type=pathlib.Path) | 
        
          |  | parser.add_argument('output_gpkg', type=pathlib.Path) | 
        
          |  | parser.add_argument('table_name') | 
        
          |  | parser.add_argument('geom_name') | 
        
          |  | parser.add_argument('attributes', action='store') | 
        
          |  | args = parser.parse_args() | 
        
          |  | input_gpkg = args.input_gpkg | 
        
          |  | output_gpkg = args.output_gpkg | 
        
          |  | table_name = args.table_name | 
        
          |  | geom_name = args.geom_name | 
        
          |  | attributes = args.attributes.split(',') | 
        
          |  | main(input_gpkg, output_gpkg, table_name, geom_name, attributes) |