mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 18:25:33 +08:00
allow for Inventory database source to be specified in main
configs. This works with sqlite and nhibernate backends, and stays with default seperate ini files for mysql and mssql until someone writes those.
This commit is contained in:
@@ -51,6 +51,12 @@ namespace OpenSim.Data.MSSQL
|
||||
/// <summary>
|
||||
/// Loads and initialises this database plugin
|
||||
/// </summary>
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
// TODO: actually use the provided connect string
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
|
||||
|
||||
@@ -51,6 +51,12 @@ namespace OpenSim.Data.MySQL
|
||||
/// <summary>
|
||||
/// Loads and initialises this database plugin
|
||||
/// </summary>
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
// TODO: actually use the provided connect string
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace OpenSim.Data.NHibernate
|
||||
|
||||
public override void Initialise(string connect)
|
||||
{
|
||||
// TODO: hard coding for sqlite based stuff to begin with, just making it easier to test
|
||||
// Split out the dialect, driver, and connect string
|
||||
char[] split = {';'};
|
||||
string[] parts = connect.Split(split);
|
||||
|
||||
// This is stubbing for now, it will become dynamic later and support different db backends
|
||||
// NHibernate setup
|
||||
cfg = new Configuration();
|
||||
cfg.SetProperty(Environment.ConnectionProvider,
|
||||
"NHibernate.Connection.DriverConnectionProvider");
|
||||
@@ -74,7 +74,11 @@ namespace OpenSim.Data.NHibernate
|
||||
using ( MemoryStream stream =
|
||||
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
|
||||
cfg.AddInputStream(stream);
|
||||
|
||||
|
||||
// If uncommented this will auto create tables, but it
|
||||
// does drops of the old tables, so we need a smarter way
|
||||
// to acturally manage this.
|
||||
|
||||
// new SchemaExport(cfg).Create(true, true);
|
||||
|
||||
factory = cfg.BuildSessionFactory();
|
||||
|
||||
@@ -50,25 +50,21 @@ namespace OpenSim.Data.NHibernate
|
||||
/// <summary>
|
||||
/// Initialises the interface
|
||||
/// </summary>
|
||||
public void Initialise()
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
Initialise("Inventory.db", "Inventory");
|
||||
}
|
||||
|
||||
public void Initialise(string dbfile, string dbname)
|
||||
{
|
||||
// TODO: hard coding for sqlite based stuff to begin with, just making it easier to test
|
||||
|
||||
// This is stubbing for now, it will become dynamic later and support different db backends
|
||||
// Split out the dialect, driver, and connect string
|
||||
char[] split = {';'};
|
||||
string[] parts = connect.Split(split);
|
||||
|
||||
// Establish NHibernate Connection
|
||||
cfg = new Configuration();
|
||||
cfg.SetProperty(Environment.ConnectionProvider,
|
||||
"NHibernate.Connection.DriverConnectionProvider");
|
||||
cfg.SetProperty(Environment.Dialect,
|
||||
"NHibernate.Dialect.SQLiteDialect");
|
||||
"NHibernate.Dialect." + parts[0]);
|
||||
cfg.SetProperty(Environment.ConnectionDriver,
|
||||
"NHibernate.Driver.SqliteClientDriver");
|
||||
cfg.SetProperty(Environment.ConnectionString,
|
||||
"URI=file:" + dbfile + ",version=3");
|
||||
"NHibernate.Driver." + parts[1]);
|
||||
cfg.SetProperty(Environment.ConnectionString, parts[2]);
|
||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||
|
||||
HbmSerializer.Default.Validate = true;
|
||||
@@ -76,6 +72,10 @@ namespace OpenSim.Data.NHibernate
|
||||
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
|
||||
cfg.AddInputStream(stream);
|
||||
|
||||
// If uncommented this will auto create tables, but it
|
||||
// does drops of the old tables, so we need a smarter way
|
||||
// to acturally manage this.
|
||||
|
||||
// new SchemaExport(cfg).Create(true, true);
|
||||
|
||||
factory = cfg.BuildSessionFactory();
|
||||
|
||||
@@ -50,17 +50,13 @@ namespace OpenSim.Data.SQLite
|
||||
/// <summary>
|
||||
/// Initialises the interface
|
||||
/// </summary>
|
||||
public void Initialise()
|
||||
public void Initialise(string dbconnect)
|
||||
{
|
||||
Initialise("inventoryStore.db", "inventoryDatabase");
|
||||
}
|
||||
|
||||
public void Initialise(string dbfile, string dbname)
|
||||
{
|
||||
string connectionString = "URI=file:" + dbfile + ",version=3";
|
||||
|
||||
m_log.Info("[Inventory]: Sqlite - connecting: " + dbfile);
|
||||
SqliteConnection conn = new SqliteConnection(connectionString);
|
||||
if (dbconnect == string.Empty) {
|
||||
dbconnect = "URI=file:inventoryStore.db,version=3";
|
||||
}
|
||||
m_log.Info("[Inventory]: Sqlite - connecting: " + dbconnect);
|
||||
SqliteConnection conn = new SqliteConnection(dbconnect);
|
||||
|
||||
conn.Open();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user