* A feeble attempt at adding Grid db support to SQLite, just adding some code based on User db. Nothing hot-wired though.

afrisby
lbsa71 2007-09-19 23:16:30 +00:00
parent 2afbf8b22b
commit 604b786d89
2 changed files with 69 additions and 3 deletions

View File

@ -192,6 +192,4 @@ namespace OpenSim.Framework.Data.SQLite
return null;
}
}
}

View File

@ -30,10 +30,11 @@ using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using libsecondlife;
using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
class SQLiteManager
class SQLiteManager : SQLiteBase
{
IDbConnection dbcon;
@ -88,6 +89,73 @@ namespace OpenSim.Framework.Data.SQLite
return (IDbCommand)dbcommand;
}
private bool TestTables(SQLiteConnection conn)
{
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM regions", conn);
SQLiteDataAdapter pDa = new SQLiteDataAdapter(cmd);
DataSet tmpDS = new DataSet();
try
{
pDa.Fill(tmpDS, "regions");
}
catch (Mono.Data.SqliteClient.SqliteSyntaxException)
{
MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
InitDB(conn);
}
return true;
}
private DataTable createRegionsTable()
{
DataTable regions = new DataTable("regions");
createCol(regions, "regionHandle", typeof(ulong));
createCol(regions, "regionName", typeof(System.String));
createCol(regions, "uuid", typeof(System.String));
createCol(regions, "regionRecvKey", typeof(System.String));
createCol(regions, "regionSecret", typeof(System.String));
createCol(regions, "regionSendKey", typeof(System.String));
createCol(regions, "regionDataURI", typeof(System.String));
createCol(regions, "serverIP", typeof(System.String));
createCol(regions, "serverPort", typeof(System.String));
createCol(regions, "serverURI", typeof(System.String));
createCol(regions, "locX", typeof( uint));
createCol(regions, "locY", typeof( uint));
createCol(regions, "locZ", typeof( uint));
createCol(regions, "eastOverrideHandle", typeof( ulong ));
createCol(regions, "westOverrideHandle", typeof( ulong ));
createCol(regions, "southOverrideHandle", typeof( ulong ));
createCol(regions, "northOverrideHandle", typeof( ulong ));
createCol(regions, "regionAssetURI", typeof(System.String));
createCol(regions, "regionAssetRecvKey", typeof(System.String));
createCol(regions, "regionAssetSendKey", typeof(System.String));
createCol(regions, "regionUserURI", typeof(System.String));
createCol(regions, "regionUserRecvKey", typeof(System.String));
createCol(regions, "regionUserSendKey", typeof(System.String));
// Add in contraints
regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] };
return regions;
}
private void InitDB(SQLiteConnection conn)
{
string createUsers = defineTable(createRegionsTable());
SQLiteCommand pcmd = new SQLiteCommand(createUsers, conn);
conn.Open();
pcmd.ExecuteNonQuery();
conn.Close();
}
/// <summary>
/// Reads a region row from a database reader
/// </summary>