MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / createOpenSeesDatabase

Method createOpenSeesDatabase

SRC/database/MySqlDatastore.cpp:770–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

768
769
770int
771MySqlDatastore::createOpenSeesDatabase(const char *projectName)
772{
773 if (query == 0) {
774 query = new char[512];
775 sizeQuery = 512;
776 }
777
778 // create the database
779 sprintf(query, "CREATE DATABASE %s", projectName);
780 if (this->execute(query) != 0) {
781 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not create the database\n";
782 return -1;
783 }
784
785 // link to the database,
786 if (mysql_select_db(&mysql, projectName) != 0) {
787 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not set the database\n";
788 return -2;
789 }
790
791 // now create the tables in the database
792 sprintf(query, "CREATE TABLE Messages ( dbTag INT NOT NULL, commitTag INT NOT NULL, size INT NOT NULL,\
793 data MEDIUMBLOB, PRIMARY KEY (dbTag, commitTag, size) )");
794
795 if (this->execute(query) != 0) {
796 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not create the Messagess table\n";
797 return -3;
798 }
799
800 sprintf(query, "CREATE TABLE Matrices ( dbTag INT NOT NULL, commitTag INT NOT NULL, size INT NOT NULL,\
801 data MEDIUMBLOB, PRIMARY KEY (dbTag, commitTag, size) )");
802
803 if (this->execute(query) != 0) {
804 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not create the Matricess table\n";
805 return -3;
806 }
807
808 sprintf(query, "CREATE TABLE Vectors ( dbTag INT NOT NULL, commitTag INT NOT NULL, size INT NOT NULL,\
809 data MEDIUMBLOB, PRIMARY KEY (dbTag, commitTag, size) )");
810
811 if (this->execute(query) != 0) {
812 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not create the Vectors table\n";
813 return -3;
814 }
815
816 sprintf(query, "CREATE TABLE IDs ( dbTag INT NOT NULL, commitTag INT NOT NULL, size INT NOT NULL,\
817 data MEDIUMBLOB, PRIMARY KEY (dbTag, commitTag, size) )");
818
819 if (this->execute(query) != 0) {
820 opserr << "MySqlDatastore::createOpenSeesDatabase() - could not create the ID's table\n";
821 return -3;
822 }
823
824
825 // done
826 return 0;
827}

Callers 1

MySqlDatastoreMethod · 0.95

Calls 1

executeMethod · 0.95

Tested by

no test coverage detected