Changing the name of an SQLite database

I’m using the two scripts at to make an SQLite database in Unity but unfortunately for me they are in Javascript and I have no experience in it, the scripts work fine but my problem is that the Database created is always called TestDB and there is always one table called TestTable and I can never modify the name of the database or the table.

All I could think of is changing the value at public var DatabaseName : String = "TestDB.sqdb"; , as this is the only place in the code where TestDB exists but this did nothing, I assume this is an easy problem to solve but I’m new to this and any help would be appreciated.

If you have already created the database/tables in your sql file, you will need to issue commands against it to rename the table(alter table).

If you want to know more, i suggest taking PAEvenson advise and learn about the sqlite database structure and commands.

Other wise from the ground up,
in the file from Unify, dbAccess.js, there is a class called dbAccess, this has a function called CreateTable. When you execute ScriptThatUsesTheDatabase.js in the start function it uses the dbAccess class and tries to open the database file by name

public var DatabaseName : String = "TestDB.sqdb";
public var TableName : String = "TestTable";

the file name “TestDB.sqdb” can be whatever, you could rename it ‘abc.sqlllllite’ and open that file, sqlite doesn’t care. Back to the start function,

function Start() {
    // Give ourselves a dbAccess object to work with, and open it
    db = new dbAccess();
    // Let's make sure we've got a table to work with as well!
    var tableName = TableName;
    var columnNames = new Array("firstName","lastName");
    var columnValues = new Array("text","text");
    try {
    catch(e) {// Do nothing - our table was already created
        //- we don't care about the error, we just don't want to see it

The usage of db.CreateTable in a try/catch does one of two things, if the database doesn’t exist when db.CreateTable is invoked, it will create it, otherwise an exception is thrown and caught in the ‘catch(e)…’ line, the exception is swallowed because the assumption is the database exception thrown will be “the table already exists…” or some such exception.

Just remember if you change the name of the database file, then that file will not exist until you run this the first time.