diff options
author | Kenneth Skovhede <kenneth@hexad.dk> | 2013-09-11 00:40:37 +0400 |
---|---|---|
committer | Kenneth Skovhede <kenneth@hexad.dk> | 2013-09-11 00:40:37 +0400 |
commit | 945bf2c4c7b6f9c721d37e54203d4703beda8ed1 (patch) | |
tree | ac8a5a356129208d8e9ed09509e57cfaecf65ab7 /Tools | |
parent | 95c694dce7335ab6ecf2e32c16bb648fd8c8b6fb (diff) |
Added SQLiteTool
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/SQLiteTool/App.config | 6 | ||||
-rw-r--r-- | Tools/SQLiteTool/AssemblyInfo.cs | 27 | ||||
-rw-r--r-- | Tools/SQLiteTool/Main.cs | 53 | ||||
-rw-r--r-- | Tools/SQLiteTool/SQLIteTool.csproj | 45 |
4 files changed, 131 insertions, 0 deletions
diff --git a/Tools/SQLiteTool/App.config b/Tools/SQLiteTool/App.config new file mode 100644 index 000000000..2ae22ede8 --- /dev/null +++ b/Tools/SQLiteTool/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup useLegacyV2RuntimeActivationPolicy="true">
+ <supportedRuntime version="v4.0"/>
+ </startup>
+</configuration>
\ No newline at end of file diff --git a/Tools/SQLiteTool/AssemblyInfo.cs b/Tools/SQLiteTool/AssemblyInfo.cs new file mode 100644 index 000000000..628b377e8 --- /dev/null +++ b/Tools/SQLiteTool/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("SQLIteTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("kenneth")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Tools/SQLiteTool/Main.cs b/Tools/SQLiteTool/Main.cs new file mode 100644 index 000000000..3840377d6 --- /dev/null +++ b/Tools/SQLiteTool/Main.cs @@ -0,0 +1,53 @@ +using System; + +namespace SQLiteTool +{ + class MainClass + { + public static void Main(string[] args) + { + if (args.Length != 2) + { + Console.WriteLine("Usage: "); + Console.WriteLine(" SQLiteTool <dbpath> <query>"); + Console.WriteLine(" <query> can be the path to a file with SQL statements or an SQL statement"); + return; + } + + using (var connection = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.Utility.SQLiteLoader.SQLiteConnectionType)) + { + connection.ConnectionString = "Data Source=" + args[0]; + connection.Open(); + + var query = args[1]; + try { query = System.IO.File.ReadAllText(args[1]); } + catch {} + + var begin = DateTime.Now; + + using(var cmd = connection.CreateCommand()) + { + cmd.CommandText = query; + using (var rd = cmd.ExecuteReader()) + { + Console.WriteLine("Execution took: {0:mm\\:ss\\.fff}", DateTime.Now - begin); + + for (int i = 0; i < rd.FieldCount; i++) + Console.Write((i == 0 ? "" : "\t") + rd.GetName(i)); + Console.WriteLine(); + + long n = 0; + while (rd.Read()) + { + for (int i = 0; i < rd.FieldCount; i++) + Console.Write(string.Format((i == 0 ? "{0}" : "\t{0}"), rd.GetValue(i))); + Console.WriteLine(); + n++; + } + Console.WriteLine("{0} records", n); + } + } + } + } + } +} diff --git a/Tools/SQLiteTool/SQLIteTool.csproj b/Tools/SQLiteTool/SQLIteTool.csproj new file mode 100644 index 000000000..8eb20e101 --- /dev/null +++ b/Tools/SQLiteTool/SQLIteTool.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3B546BD0-7549-4CE3-9B68-5C149B8AA2E7}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>SQLiteTool</RootNamespace>
+ <AssemblyName>SQLiteTool</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ <DefineConstants>DEBUG</DefineConstants>
+ <DebugSymbols>true</DebugSymbols>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>False</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Main.cs" />
+ <Compile Include="AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\..\Duplicati\Library\Utility\Duplicati.Library.Utility.csproj">
+ <Project>{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}</Project>
+ <Name>Duplicati.Library.Utility</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+</Project>
\ No newline at end of file |