.NETヘルプ DuckDB C#(開発者向けの仕組み) Curtis Chau 更新日:7月 28, 2025 Download IronPDF NuGet Download テキストの検索と置換 テキストと画像のスタンプ Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article DuckDB.NET は、C#とシームレスに統合するように設計された DuckDB ネイティブライブラリ用の .NET バインディングのオープンソースプロバイダーです。 ADO.NET プロバイダーを提供するため、.NET アプリケーションで低レベルのバインディングライブラリである DuckDB を簡単に使用できます。 このパッケージは、DuckDB の強力な分析機能を C# 環境で活用しようとしている開発者に最適です。 インストール DuckDB.NET のインストールは簡単です。 あなたのプロジェクトに .NET CLI を使って追加できます。 dotnet add package DuckDB.NET.Data.Full dotnet add package DuckDB.NET.Data.Full SHELL また、Visual Studio の NuGet パッケージ マネージャーを使用してインストールすることもできます。 基本的な使い方 一度インストールしたら、DuckDB.NET を使って C# アプリケーション内で SQL クエリを実行し始めることができます。 using System; using DuckDB.NET.Data; class Program { static void Main() { // Create and open a connection to an in-memory DuckDB database using var duckdbconnection = new DuckDBConnection("Data Source=:memory:"); duckdbconnection.Open(); // Create a command associated with the connection using var command = duckdbconnection.CreateCommand(); // Create a table named 'integers' command.CommandText = "CREATE TABLE integers(foo INTEGER, bar INTEGER);"; command.ExecuteNonQuery(); // Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);"; command.ExecuteNonQuery(); // Retrieve the count of rows in the 'integers' table command.CommandText = "SELECT count(*) FROM integers"; var executeScalar = command.ExecuteScalar(); // Select all values from the 'integers' table command.CommandText = "SELECT foo, bar FROM integers;"; // Execute the query and process the results using var reader = command.ExecuteReader(); while (reader.Read()) { Console.WriteLine($"{reader.GetInt32(0)}, {reader.GetInt32(1)}"); } } } using System; using DuckDB.NET.Data; class Program { static void Main() { // Create and open a connection to an in-memory DuckDB database using var duckdbconnection = new DuckDBConnection("Data Source=:memory:"); duckdbconnection.Open(); // Create a command associated with the connection using var command = duckdbconnection.CreateCommand(); // Create a table named 'integers' command.CommandText = "CREATE TABLE integers(foo INTEGER, bar INTEGER);"; command.ExecuteNonQuery(); // Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);"; command.ExecuteNonQuery(); // Retrieve the count of rows in the 'integers' table command.CommandText = "SELECT count(*) FROM integers"; var executeScalar = command.ExecuteScalar(); // Select all values from the 'integers' table command.CommandText = "SELECT foo, bar FROM integers;"; // Execute the query and process the results using var reader = command.ExecuteReader(); while (reader.Read()) { Console.WriteLine($"{reader.GetInt32(0)}, {reader.GetInt32(1)}"); } } } Imports System Imports DuckDB.NET.Data Friend Class Program Shared Sub Main() ' Create and open a connection to an in-memory DuckDB database Dim duckdbconnection As New DuckDBConnection("Data Source=:memory:") duckdbconnection.Open() ' Create a command associated with the connection Dim command = duckdbconnection.CreateCommand() ' Create a table named 'integers' command.CommandText = "CREATE TABLE integers(foo INTEGER, bar INTEGER);" command.ExecuteNonQuery() ' Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);" command.ExecuteNonQuery() ' Retrieve the count of rows in the 'integers' table command.CommandText = "SELECT count(*) FROM integers" Dim executeScalar = command.ExecuteScalar() ' Select all values from the 'integers' table command.CommandText = "SELECT foo, bar FROM integers;" ' Execute the query and process the results Dim reader = command.ExecuteReader() Do While reader.Read() Console.WriteLine($"{reader.GetInt32(0)}, {reader.GetInt32(1)}") Loop End Sub End Class $vbLabelText $csharpLabel この例は、DuckDB.NET を使用してテーブルを作成し、データを挿入およびクエリする方法を示しています。 出力 データの取り込み DuckDB.NET は、CSV や Parquet ファイルを含むさまざまな形式からのデータの読み取りをサポートしています。 ここでは、CSV ファイルからデータを読む方法を示します。 command.CommandText = "COPY integers FROM 'example.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); command.CommandText = "COPY integers FROM 'example.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel データフレームとの統合 DuckDB.NET は、データフレームと統合することもでき、慣れ親しんだ SQL 構文を使用してデータを操作できます。 これは特にデータ分析タスクに役立ちます。 結果の変換 クエリの結果を一覧やカスタムオブジェクトに変換でき、アプリケーションでデータを簡単に操作できます。 var results = new List<(int foo, int bar)>(); // Read and store results to a List while (reader.Read()) { results.Add((reader.GetInt32(0), reader.GetInt32(1))); // You can also use a loop with an index to iterate the results } var results = new List<(int foo, int bar)>(); // Read and store results to a List while (reader.Read()) { results.Add((reader.GetInt32(0), reader.GetInt32(1))); // You can also use a loop with an index to iterate the results } Dim results = New List(Of (foo As Integer, bar As Integer))() ' Read and store results to a List Do While reader.Read() results.Add((reader.GetInt32(0), reader.GetInt32(1))) ' You can also use a loop with an index to iterate the results Loop $vbLabelText $csharpLabel ディスクへのデータ書き込み DuckDB.NET は、さまざまな形式でディスクにデータを書き込むことをサポートしています。 COPY ステートメントを使用してデータを CSV ファイルにエクスポートできます。 command.CommandText = "COPY integers TO 'output.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); command.CommandText = "COPY integers TO 'output.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel IronPDFの紹介 IronPDF は、.NET プロジェクトでの PDF ドキュメントの生成、管理、およびコンテンツの抽出を可能にする C# 用 PDF ライブラリです。 ここにいくつかの主な機能があります: IronPDF は、ウェブページ、URL、HTML を PDF に変換する便利なツールです。 一番のポイントは何ですか? PDF は元のウェブページとまったく同じに見えます – すべてのフォーマットとスタイルを保持しています。 オンラインのレポートや請求書などから PDF を作成する必要がある場合、IronPDF は頼りになるツールです。 using IronPdf; class Program { static void Main(string[] args) { var renderer = new ChromePdfRenderer(); // 1. Convert HTML String to PDF var htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a PDF from an HTML string.</p>"; var pdfFromHtmlString = renderer.RenderHtmlAsPdf(htmlContent); pdfFromHtmlString.SaveAs("HTMLStringToPDF.pdf"); // 2. Convert HTML File to PDF var htmlFilePath = "path_to_your_html_file.html"; // Specify the path to your HTML file var pdfFromHtmlFile = renderer.RenderHtmlFileAsPdf(htmlFilePath); pdfFromHtmlFile.SaveAs("HTMLFileToPDF.pdf"); // 3. Convert URL to PDF var url = "http://ironpdf.com"; // Specify the URL var pdfFromUrl = renderer.RenderUrlAsPdf(url); pdfFromUrl.SaveAs("URLToPDF.pdf"); } } using IronPdf; class Program { static void Main(string[] args) { var renderer = new ChromePdfRenderer(); // 1. Convert HTML String to PDF var htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a PDF from an HTML string.</p>"; var pdfFromHtmlString = renderer.RenderHtmlAsPdf(htmlContent); pdfFromHtmlString.SaveAs("HTMLStringToPDF.pdf"); // 2. Convert HTML File to PDF var htmlFilePath = "path_to_your_html_file.html"; // Specify the path to your HTML file var pdfFromHtmlFile = renderer.RenderHtmlFileAsPdf(htmlFilePath); pdfFromHtmlFile.SaveAs("HTMLFileToPDF.pdf"); // 3. Convert URL to PDF var url = "http://ironpdf.com"; // Specify the URL var pdfFromUrl = renderer.RenderUrlAsPdf(url); pdfFromUrl.SaveAs("URLToPDF.pdf"); } } Imports IronPdf Friend Class Program Shared Sub Main(ByVal args() As String) Dim renderer = New ChromePdfRenderer() ' 1. Convert HTML String to PDF Dim htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a PDF from an HTML string.</p>" Dim pdfFromHtmlString = renderer.RenderHtmlAsPdf(htmlContent) pdfFromHtmlString.SaveAs("HTMLStringToPDF.pdf") ' 2. Convert HTML File to PDF Dim htmlFilePath = "path_to_your_html_file.html" ' Specify the path to your HTML file Dim pdfFromHtmlFile = renderer.RenderHtmlFileAsPdf(htmlFilePath) pdfFromHtmlFile.SaveAs("HTMLFileToPDF.pdf") ' 3. Convert URL to PDF Dim url = "http://ironpdf.com" ' Specify the URL Dim pdfFromUrl = renderer.RenderUrlAsPdf(url) pdfFromUrl.SaveAs("URLToPDF.pdf") End Sub End Class $vbLabelText $csharpLabel HTML を PDF に変換: HTML、CSS、および JavaScript コンテンツを PDF に変換します。 ピクセル パーフェクトな PDF ドキュメントのための Chrome レンダリング エンジン。 URL、HTML ファイル、または HTML 文字列から PDF を生成します。 画像およびコンテンツの変換: 画像を PDF ドキュメントに変換、またはその逆。 存在する PDF ドキュメントからテキストや画像を抽出します。 JPG、PNG などのさまざまな画像形式をサポート。 編集および操作: PDF ドキュメントのプロパティ、セキュリティ、および権限を設定。 PDF にデジタル署名を追加。 メタデータや履歴を編集。 クロスプラットフォーム サポート: .NET Core (8、7、6、5、および 3.1+)、.NET Standard (2.0+)、.NET Framework (4.6.2+) 対応。 Windows、Linux、および macOS 互換。 NuGet で簡単にインストール可能。 IronPDF および DuckDB .NET を使用して PDF ドキュメントを生成する はじめに、以下のように Visual Studio を使用してコンソールアプリケーションを作成します。 プロジェクト名を入力します。 .NET バージョンを入力します。 IronPDF パッケージをインストールします。 DuckDB.NET パッケージをインストールします。 using DuckDB.NET.Data; using IronPdf; namespace CodeSample { public static class DuckDbDemo { public static void Execute() { // Instantiate Renderer var renderer = new ChromePdfRenderer(); var content = "<h1>Demo DuckDb and IronPDF</h1>"; content += "<h2>Create DuckDBConnection</h2>"; content += "<p>new DuckDBConnection(\"Data Source=:memory:\");</p>"; content += "<p></p>"; // Create and open a connection to an in-memory DuckDB database using var connection = new DuckDBConnection("Data Source=:memory:"); connection.Open(); using var command = connection.CreateCommand(); // Create a table named 'integers' command.CommandText = "CREATE TABLE integers(book STRING, cost INTEGER);"; command.ExecuteNonQuery(); content += "<p>CREATE TABLE integers(book STRING, cost INTEGER);</p>"; // Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);"; command.ExecuteNonQuery(); content += "<p>INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);</p>"; // Select all values from the 'integers' table command.CommandText = "SELECT book, cost FROM integers;"; using var reader = command.ExecuteReader(); content += "<p>SELECT book, cost FROM integers;</p>"; // Execute the query and process the results, appending them to the HTML content while (reader.Read()) { content += $"<p>{reader.GetString(0)}, {reader.GetInt32(1)}</p>"; Console.WriteLine($"{reader.GetString(0)}, {reader.GetInt32(1)}"); } // Save data to CSV content += "<p>Save data to CSV with COPY integers TO 'output.csv' (FORMAT CSV);</p>"; command.CommandText = "COPY integers TO 'output.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); // Generate and save PDF var pdf = renderer.RenderHtmlAsPdf(content); pdf.SaveAs("AwesomeDuckDbNet.pdf"); } } } using DuckDB.NET.Data; using IronPdf; namespace CodeSample { public static class DuckDbDemo { public static void Execute() { // Instantiate Renderer var renderer = new ChromePdfRenderer(); var content = "<h1>Demo DuckDb and IronPDF</h1>"; content += "<h2>Create DuckDBConnection</h2>"; content += "<p>new DuckDBConnection(\"Data Source=:memory:\");</p>"; content += "<p></p>"; // Create and open a connection to an in-memory DuckDB database using var connection = new DuckDBConnection("Data Source=:memory:"); connection.Open(); using var command = connection.CreateCommand(); // Create a table named 'integers' command.CommandText = "CREATE TABLE integers(book STRING, cost INTEGER);"; command.ExecuteNonQuery(); content += "<p>CREATE TABLE integers(book STRING, cost INTEGER);</p>"; // Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);"; command.ExecuteNonQuery(); content += "<p>INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);</p>"; // Select all values from the 'integers' table command.CommandText = "SELECT book, cost FROM integers;"; using var reader = command.ExecuteReader(); content += "<p>SELECT book, cost FROM integers;</p>"; // Execute the query and process the results, appending them to the HTML content while (reader.Read()) { content += $"<p>{reader.GetString(0)}, {reader.GetInt32(1)}</p>"; Console.WriteLine($"{reader.GetString(0)}, {reader.GetInt32(1)}"); } // Save data to CSV content += "<p>Save data to CSV with COPY integers TO 'output.csv' (FORMAT CSV);</p>"; command.CommandText = "COPY integers TO 'output.csv' (FORMAT CSV);"; command.ExecuteNonQuery(); // Generate and save PDF var pdf = renderer.RenderHtmlAsPdf(content); pdf.SaveAs("AwesomeDuckDbNet.pdf"); } } } Imports DuckDB.NET.Data Imports IronPdf Namespace CodeSample Public Module DuckDbDemo Public Sub Execute() ' Instantiate Renderer Dim renderer = New ChromePdfRenderer() Dim content = "<h1>Demo DuckDb and IronPDF</h1>" content &= "<h2>Create DuckDBConnection</h2>" content &= "<p>new DuckDBConnection(""Data Source=:memory:"");</p>" content &= "<p></p>" ' Create and open a connection to an in-memory DuckDB database Dim connection = New DuckDBConnection("Data Source=:memory:") connection.Open() Dim command = connection.CreateCommand() ' Create a table named 'integers' command.CommandText = "CREATE TABLE integers(book STRING, cost INTEGER);" command.ExecuteNonQuery() content &= "<p>CREATE TABLE integers(book STRING, cost INTEGER);</p>" ' Insert some data into the 'integers' table command.CommandText = "INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);" command.ExecuteNonQuery() content &= "<p>INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);</p>" ' Select all values from the 'integers' table command.CommandText = "SELECT book, cost FROM integers;" Dim reader = command.ExecuteReader() content &= "<p>SELECT book, cost FROM integers;</p>" ' Execute the query and process the results, appending them to the HTML content Do While reader.Read() content &= $"<p>{reader.GetString(0)}, {reader.GetInt32(1)}</p>" Console.WriteLine($"{reader.GetString(0)}, {reader.GetInt32(1)}") Loop ' Save data to CSV content &= "<p>Save data to CSV with COPY integers TO 'output.csv' (FORMAT CSV);</p>" command.CommandText = "COPY integers TO 'output.csv' (FORMAT CSV);" command.ExecuteNonQuery() ' Generate and save PDF Dim pdf = renderer.RenderHtmlAsPdf(content) pdf.SaveAs("AwesomeDuckDbNet.pdf") End Sub End Module End Namespace $vbLabelText $csharpLabel コードの説明 このコードは、DuckDB.NET をデータベース操作に使用し、データベースクエリ結果を含む PDF レポートを生成するために IronPDF を使用する方法を実演することを目的としています。 キー コンポーネント DuckDB.NET: DuckDBConnection: インメモリの DuckDB データベースファイル ("Data Source=:memory:") への接続を確立します。 この接続は SQL コマンドを実行するためにコード全体で使用されます。 データベース操作: テーブル作成: book (STRING) と cost (INTEGER) という列を持つ integers という名前のテーブルを作成するための SQL コマンド (CREATE TABLE integers(book STRING, cost INTEGER);) を定義。 データ挿入: integers テーブルに行を挿入 (INSERT INTO integers VALUES ('book1', 25), ('book2', 30), ('book3', 10);)。 データ取得: integers テーブルからデータをフェッチする SELECT クエリ (SELECT book, cost FROM integers;) を実行します。 取得したデータは HTML (content) にフォーマットされ、コンソールに出力されます。 IronPDF を使用した PDF 生成: HTML を PDF にレンダリング: IronPDF の ChromePdfRenderer を使用して HTML コンテンツ (content) を PDF ドキュメント (pdf) に変換します。 PDF 保存: 作成された PDF を現在のディレクトリに "AwesomeDuckDbNet.pdf" として保存します。 出力 PDF IronPDF ライセンス IronPDF パッケージは実行するためにライセンスが必要です。 パッケージにアクセスする前にアプリケーションの冒頭に以下のコードを追加してください。 IronPdf.License.LicenseKey = "IRONPDF-KEY"; IronPdf.License.LicenseKey = "IRONPDF-KEY"; IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel IronPDF の試用ライセンスページで試用ライセンスを入手できます。 結論 DuckDB.NET C#パッケージは、.NETアプリケーションに DuckDB の分析機能を統合するための強力なツールです。 その使いやすさ、さまざまなデータ形式のサポート、および C# とのシームレスな統合により、データ集約型アプリケーションに取り組む開発者にとって優れた選択肢です。 データ分析ツール、ETL パイプライン、またはその他のデータ駆動型アプリケーションを構築する場合でも、DuckDB.NET は目標を効率的に達成するのに役立ちます。 よくある質問 DuckDB.NETはC#アプリケーションでどのように使用されますか? DuckDB.NETはC#アプリケーション内でDuckDBネイティブライブラリを統合し、ADO.NETプロバイダーを通じて開発者に強力な分析機能を提供します。 C#プロジェクトにDuckDB.NETをインストールするにはどうすればいいですか? .NET CLIコマンドdotnet add package DuckDB.NET.Data.Fullを使うか、Visual StudioのNuGetパッケージマネージャーを通じてDuckDB.NETをインストールできます。 DuckDB.NETを使ってSQLクエリを実行するにはどうすればいいですか? DuckDBConnectionを確立して接続し、SQLコマンドを実行してテーブルを作成、データの挿入、取得を行います。 DuckDB.NETはCSVやParquetファイルからデータを読み込むことをサポートしていますか? はい、DuckDB.NETはCSVやParquetファイルを含む様々な形式からのデータ取り込みをサポートしており、C#アプリケーション内でこれらのデータ型をシームレスに統合および操作できます。 C# で HTML を PDF に変換するにはどうすればいいですか? IronPDF の RenderHtmlAsPdf メソッドを使用して、HTML 文字列を PDF に変換できます。RenderHtmlFileAsPdf を使用して HTML ファイルを PDF に変換することもできます。 データ集中型プロジェクトでDuckDB.NETを使う利点は何ですか? DuckDB.NETは強力な分析機能、SQLベースのデータ操作をサポートし、C#アプリケーションと簡単に統合できるため、データ集中型プロジェクトに最適です。 DuckDB.NETはどのようにデータフレームと統合できますか? DuckDB.NETはデータフレームとの統合が可能で、SQLベースのデータ操作を実現し、複雑なデータ分析タスクに特に役立ちます。 DuckDB.NETを使ってCSVファイルにデータをエクスポートするにはどうすればいいですか? DuckDB.NETではCOPYステートメントを使ってCSVファイルにデータをエクスポートできます。例えば、COPY integers TO 'output.csv' (FORMAT CSV);を使ってテーブルデータをCSVファイルにエクスポートします。 IronPDFはどのプラットフォームをサポートしていますか? IronPDFは.NET Core (8, 7, 6, 5, および3.1+)、.NET Standard (2.0+) 、および.NET Framework (4.6.2+ )をサポートしており、Windows、Linux、およびmacOSと互換性があります。 DuckDB.NETとIronPDFを組み合わせてレポートを生成できますか? はい、DuckDB.NETをデータベース操作に、IronPDFをPDFレポート生成に使用して、DuckDBのデータベース機能とIronPDFのPDF生成機能を活用できます。 Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 関連する記事 更新日 9月 4, 2025 RandomNumberGenerator C# RandomNumberGenerator C#クラスを使用すると、PDF生成および編集プロジェクトを次のレベルに引き上げることができます 詳しく読む 更新日 9月 4, 2025 C# String Equals(開発者向けの仕組み) 強力なPDFライブラリであるIronPDFと組み合わせることで、switchパターンマッチングは、ドキュメント処理のためのよりスマートでクリーンなロジックを構築できます 詳しく読む 更新日 8月 5, 2025 C# Switch Pattern Matching(開発者向けの仕組み) 強力なPDFライブラリであるIronPDFと組み合わせることで、switchパターンマッチングは、ドキュメント処理のためのよりスマートでクリーンなロジックを構築できます 詳しく読む LazyCache C#(開発者向けの仕組み)WebGrease .NET Core(開発者向...
更新日 9月 4, 2025 RandomNumberGenerator C# RandomNumberGenerator C#クラスを使用すると、PDF生成および編集プロジェクトを次のレベルに引き上げることができます 詳しく読む
更新日 9月 4, 2025 C# String Equals(開発者向けの仕組み) 強力なPDFライブラリであるIronPDFと組み合わせることで、switchパターンマッチングは、ドキュメント処理のためのよりスマートでクリーンなロジックを構築できます 詳しく読む
更新日 8月 5, 2025 C# Switch Pattern Matching(開発者向けの仕組み) 強力なPDFライブラリであるIronPDFと組み合わせることで、switchパターンマッチングは、ドキュメント処理のためのよりスマートでクリーンなロジックを構築できます 詳しく読む