from osgeo import ogr

from rosreestrXml.ui.tools.db_helper.dbRsc import DbRsc

path_sourcer=r"E:\Download\RossRestr\newEGRN\test_import.gpkg"
name_layer='view_land_record'
name_layer_new='spatial_land_record'
db=DbRsc(path_sourcer)
''' обновление структуры табли'''
sql="select name AS column_name,type AS column_type FROM  pragma_table_info('"+name_layer+"')"
rows=db.select(sql)
def_names=[]
for row in rows:
    def_names.append({"name":row[0],'type':row[1]})
for name_def in def_names:
    if name_def['name']=='parent_row_id' or name_def['name']=='geom':
        continue
    sql_alter="ALTER TABLE "+name_layer_new+" ADD COLUMN "+name_def['name']+" "+name_def['type']
    db.runSqlNoResult(sql_alter)
db.close()
print("end")