MCPcopy Index your code
hub / github.com/questdb/questdb / main

Function main

benchmarks/src/main/python/insert_bench.py:71–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71async def main():
72 db_config = {
73 'host': 'localhost',
74 'port': 5432,
75 'user': 'admin',
76 'password': 'quest',
77 'database': 'qdb'
78 }
79
80 pool = await asyncpg.create_pool(**db_config, min_size=20, max_size=20)
81
82 try:
83 await create_table(pool)
84
85 print("Generating test data...")
86 records = generate_test_data(1_000_000)
87
88 start_time = datetime.now()
89
90 print("Starting batch insert...")
91 await batch_insert(pool, records)
92
93 end_time = datetime.now()
94 duration = (end_time - start_time).total_seconds()
95
96 print(f"Successfully inserted 1,000,000 records in {duration:.2f} seconds")
97 print(f"Average insertion rate: {1_000_000 / duration:.2f} records/second")
98
99 finally:
100 await pool.close()
101
102
103if __name__ == '__main__':

Callers 1

insert_bench.pyFile · 0.70

Calls 4

create_tableFunction · 0.85
generate_test_dataFunction · 0.85
batch_insertFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…