Tdd create

From TaskDepender
Jump to: navigation, search
(Implementation)
 
Line 8: Line 8:
 
  * Creates the TaskDepender database in the specified file.
 
  * Creates the TaskDepender database in the specified file.
 
  */
 
  */
int tdd_create
+
HANDLE tdd_create
 
(
 
(
 
   char *filename // Filename of the database file to create.
 
   char *filename // Filename of the database file to create.
Line 17: Line 17:
 
== Design ==
 
== Design ==
  
To create a TaskDepender database the following steps are taken:
+
To create a TaskDepender database the following steps are taken.
#  
+
 
 +
# Create a new database and open it for reading and writing.
 +
# Create the [[Tasks database table|tasks table]].
 +
# Create the [[Deliverables database table|deliverables table]].
 +
# Create the [[Connections database table|connections table]].
 +
# Create the temporary [[Task list database table|task-list table]].
 +
# Create the temporary [[Deliverable list database table|deliverable-list table]].
 +
# Create the temporary [[Connection list database table|connection-list table]].
 +
 
 +
 
 +
 
 +
To open and create a new database, the <tt>[http://www.sqlite.org/c3ref/open.html sqlite3_open_v2()]</tt> is used.
  
 
== Implementation ==
 
== Implementation ==
  
 +
<syntaxhighlight lang="c">
 +
HANDLE tdd_create
 +
(
 +
  char *filename // Filename of the database file to create.
 +
)
 +
{
 +
  sqlite3 *db;
 +
  rc = sqlite3_open_v2(filename,&db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,NULL);
 +
 +
  if(rc)
 +
  {
 +
    sqlite3_close(db);
 +
    return &db;   
 +
  }
 +
 +
  // -- Create tasks table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_TASKS_TABLE, NULL, NULL, &dbError );
 +
 
 +
  // -- Create deliverables table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_DELIVERABLES_TABLE, NULL, NULL, &dbError );
 +
 +
  // -- Create the connections table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_CONNECTIONS_TABLE, NULL, NULL, &dbError );
 +
 +
  // -- Create the temporary task-list table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_TASKLIST_TABLE, NULL, NULL, &dbError );
 +
 +
  // -- Create the temporary deliverable-list table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_TASKS_TABLE, NULL, NULL, &dbError );
 +
 +
  // -- Create the temporary connection-list table --
 +
  rc = sqlite3_exec(db, TDD_CREATE_TASKS_TABLE, NULL, NULL, &dbError );
 +
 +
 +
 +
 +
  return &db;
 +
}
 +
</syntaxhighlight>
  
  
 
----
 
----
 
* [[Database]]
 
* [[Database]]

Latest revision as of 10:31, 22 October 2011