Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CreateUserTable()
- {
- QSqlQuery query;
- QString str = "CREATE TABLE user ( "
- "id INTEGER PRIMARY KEY NOT NULL, "
- "username VARCHAR(20), "
- "password VARCHAR(20), "
- "UNIQUE (username) "
- ");";
- if (!query.exec(str)) {
- qDebug() << "Unable to create table";
- }else{
- qDebug() << "create user table";
- }
- }
- void CreateAmountTable()
- {
- QSqlQuery query;
- QString str = "CREATE TABLE amount ( "
- "id INTEGER PRIMARY KEY NOT NULL, "
- "reason VARCHAR(144), "
- "summ VARCHAR(144), "
- "author INTEGER, "
- "FOREIGN KEY(author) REFERENCES user(id)"
- ");";
- if (!query.exec(str)) {
- qDebug() << "Unable to create table";
- }else{
- qDebug() << "create Amount table";
- }
- }
- void CreateCostsTable()
- {
- QSqlQuery query;
- QString str = "CREATE TABLE costs ( "
- "id INTEGER PRIMARY KEY NOT NULL, "
- "reason VARCHAR(144), "
- "summ VARCHAR(144) "
- "author INTEGER, "
- "FOREIGN KEY(author) REFERENCES user(id)"
- ");";
- if (!query.exec(str)) {
- qDebug() << "Unable to create table";
- }else{
- qDebug() << "create cost table";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement