Coder Social home page Coder Social logo

sqlite-table-structure-updater's Introduction

SQLite Table Structure Updater

Usage:

  • Update via Web Form:

    • Enter Location of your SQLite Database File
    • Enter Location of your New Table Structures File
      • must be a PHP file that sets array $tables in format: $tables['name'] = "CREATE TABLE 'name' ( ... )";
    • Click Run Updater
  • Update via Code:

use Attogram\SQLiteTableStructureUpdater;

require_once('SQLiteTableStructureUpdater.php');

$updater = new SQLiteTableStructureUpdater();
//$updater->debug = TRUE; // debug mode

if( !$updater->set_database_file('./your-database-file.sqlite') ) {
    // handle error
}

// Set new table structures:
// Set array $tables in format: $tables[TABLE_NAME] = TABLE_SQL;

// Set new table structures via external file:
include('./your-new-table-structure-file.php');

// Or Set new table structures directly:
$tables = array(
    'a_table' => "CREATE TABLE 'a_table' ( 'id' INTEGER PRIMARY KEY, 'foo' TEXT )",
    'b_table' => "CREATE TABLE 'b_table' ( 'id' INTEGER PRIMARY KEY, 'bar' TEXT )",
);
$tables['c_table'] = "CREATE TABLE 'c_table' ( 'id' INTEGER PRIMARY KEY, 'foobar' TEXT )";

if( !$updater->set_new_structures( $tables ) ) {
    // handle error
}

$updater->update();

License

  • MIT License

TODO

  • option to delete or keep backup tables
  • silent option: no debug(), notice() nor error()
  • normalize_sql() - remove any trailing semi-colons ;

sqlite-table-structure-updater's People

Contributors

attogram avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.