-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ADO.NET importing/exporting functionality to DataFrame (#5975)
* refactoring - removed copy/paste in DataFrame.CreateColumn() * added a universal loading method and export to DataTable * added tests for new loading/saving methods in DataFrame * improved error handling - DataFrame.LoadFrom() * DataFrame - importing and exporting data using ADO.NET providers * DataFrame.LoadFrom() - use async * DataFrame.LoadFrom() - minor refactorings * Update Microsoft.Data.Analysis.Tests.csproj Changed version of System.Data.SQLite * Update Microsoft.Data.Analysis.Tests.csproj * fixed chown command * sql db test path change * sql db test path change * sql db test fix * sql db test fix --------- Co-authored-by: Michael Sharp <51342856+michaelgsharp@users.noreply.github.com> Co-authored-by: Michael Sharp <misharp@microsoft.com>
- Loading branch information
1 parent
ff3b1b9
commit 3d705bf
Showing
6 changed files
with
334 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.Common; | ||
using System.Text; | ||
|
||
namespace Microsoft.Data.Analysis | ||
{ | ||
public static class Extensions | ||
{ | ||
public static DbDataAdapter CreateDataAdapter(this DbProviderFactory factory, DbConnection connection, string tableName) | ||
{ | ||
var query = connection.CreateCommand(); | ||
query.CommandText = $"SELECT * FROM {tableName}"; | ||
var res = factory.CreateDataAdapter(); | ||
res.SelectCommand = query; | ||
return res; | ||
} | ||
|
||
public static bool TryOpen(this DbConnection connection) | ||
{ | ||
if (connection.State == ConnectionState.Closed) | ||
{ | ||
connection.Open(); | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.