import in chunks to avoid smaller systems chocking
This commit is contained in:
parent
497e1b739a
commit
0233045959
|
@ -71,21 +71,25 @@ async def import_osm(connection, filename, import_group=None):
|
||||||
|
|
||||||
# Pass 2: Import
|
# Pass 2: Import
|
||||||
log.info("Pass 2: Import roads")
|
log.info("Pass 2: Import roads")
|
||||||
async with cursor.copy(
|
amount = 0
|
||||||
"COPY road (way_id, name, zone, directionality, oneway, geometry, import_group) FROM STDIN"
|
for items in chunk(read_file(filename), 10000):
|
||||||
) as copy:
|
amount += 10000
|
||||||
for item in read_file(filename):
|
log.info(f"...{amount}/{len(ids)} ({100*amount/len(ids)}%)")
|
||||||
await copy.write_row(
|
async with cursor.copy(
|
||||||
(
|
"COPY road (way_id, name, zone, directionality, oneway, geometry, import_group) FROM STDIN"
|
||||||
item.way_id,
|
) as copy:
|
||||||
item.name,
|
for item in items:
|
||||||
item.zone,
|
await copy.write_row(
|
||||||
item.directionality,
|
(
|
||||||
item.oneway,
|
item.way_id,
|
||||||
bytes.hex(item.geometry),
|
item.name,
|
||||||
import_group,
|
item.zone,
|
||||||
|
item.directionality,
|
||||||
|
item.oneway,
|
||||||
|
bytes.hex(item.geometry),
|
||||||
|
import_group,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
Loading…
Reference in a new issue