简体   繁体   中英

How can I import data from a CSV file to a Postgres database in a transaction with ASP.NET Core?

I have a web app, in which a user can upload a CSV file with some data. I'd like to insert the data to the database, but as a transaction; either the whole CSV data gets inserted or non at all.

There is a possibilty that application call the PostgreSQL client API (libpq) to use the SQL COPY command but I don't know if this is possible with ASP.NET Core.

See COPY command https://www.postgresql.org/docs/12/sql-copy.html and COPY functions in libpq https://www.postgresql.org/docs/12/libpq-copy.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM