批量更新到数据库

问题描述:

您好,我正在解析一个日志文件,我需要首先进行插入行 - > QUERY ROW - >更新行

在解析日志文件时,所有上述操作都在不同的时间发生。约。如果我必须INSERT(打开和关闭连接),QUERY(打开和关闭连接)和UPDATE(打开和关闭连接),则有15000行,每次都很昂贵。

有没有我可以使用类似于数据集的方法,我可以在数据集上工作(用于存储而不总是访问数据库),并且在完成解析时,我可以直接将所有15000行插入到数据库中。像这样工作时,内存完全不是问题。我不想总是打开和关闭数据库连接。

Hi there, I am parsing a log file and there's a need where I have to first

INSERT ROW --> QUERY ROW --> UPDATE ROW

All of the above operations happen at different times when parsing the log file. Approx. there are 15000 rows and each time its expensive if I have to INSERT (Open & Close connection), QUERY (Open & Close connection) and UPDATE (Open & Close connection).

Is there a way where I can use something similar to a Dataset where I can work just on the Dataset (for storing without always going to database) and when parsing is completed I can directly INSERT all the 15000 rows at once into database. Memory is not at all a problem when working like this. I dont want to always open and close DB connection.

也许你对你正在使用的数据库有所了解,是在同一台机器上还是在其他计算机上?
不同的数据库引擎有不同的导入数据的方法,通常是从本地硬盘中获取数据。
Maybe you shed some light on what database you are using, is it on the same machine or some other computer?
Different DB engines have different methods for importing data, usually they take it from a local hard disk.