modified to accept hostname and connect to the network
[csql.git] / test / dbapi / Table / spaceusedtest.c
blob5b45c61ae54d2e633005b16b33590e46c9ead46c
1 /* create table 't1' with two fields f1 int, f2 int.
2 * use spaceused() to know the size of the table,
3 * here the table size will be 16 bytes.
4 *
5 * AUTHOR : Jitendra Lenka
6 */
8 #include<CSql.h>
9 int main()
11 Connection conn;
12 DbRetVal rv = conn.open("root","manager");
13 if(rv!=OK)return 1;
14 DatabaseManager *dbMgr = conn.getDatabaseManager();
15 if(dbMgr == NULL)
17 printf("Auth failed\n");
18 return 2;
21 TableDef tabDef;
22 tabDef.addField("f1",typeInt,0,NULL,true);
23 tabDef.addField("f2",typeInt);
25 rv = dbMgr->createTable("t1",tabDef);
26 if(rv!=OK)
28 printf("Table created failed\n");
29 conn.close();
30 return 0;
34 Table *table = dbMgr->openTable("t1");
35 long spaceused;
36 spaceused = table->spaceUsed();
37 printf("Total space used=%ld\n",spaceused);
39 dbMgr->closeTable(table);
40 dbMgr->dropTable("t1");
41 conn.close();
42 return 0;