Adding classes to make querying between sqlite/mysql easier
This commit is contained in:
parent
012b4e3614
commit
4bab43466c
9 changed files with 179 additions and 14 deletions
28
TShockAPI/DB/IQueryCreator.cs
Normal file
28
TShockAPI/DB/IQueryCreator.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TShockAPI.DB
|
||||
{
|
||||
public interface IQuery
|
||||
{
|
||||
string CreateTable(SqlTable table);
|
||||
}
|
||||
|
||||
public class SqliteQuery : IQuery
|
||||
{
|
||||
public string CreateTable(SqlTable table)
|
||||
{
|
||||
var columns = table.Columns.Select(c => "'{0}' {1} {2} {3} {4}".SFormat(c.Name, c.Type, c.Primary ? "PRIMARY KEY" : "", c.AutoIncrement ? "AUTOINCREMENT" : "", c.NotNull ? "NOT NULL" : "", c.Unique ? "UNIQUE" : ""));
|
||||
return "CREATE TABLE '{0}' ({1})".SFormat(table.Name, string.Join(", ", columns));
|
||||
}
|
||||
}
|
||||
public class MysqlQuery : IQuery
|
||||
{
|
||||
public string CreateTable(SqlTable table)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue