Advertisement
Guest User

Untitled

a guest
May 29th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. void CreateUserTable()
  2. {
  3. QSqlQuery query;
  4. QString str = "CREATE TABLE user ( "
  5. "id INTEGER PRIMARY KEY NOT NULL, "
  6. "username VARCHAR(20), "
  7. "password VARCHAR(20), "
  8. "UNIQUE (username) "
  9. ");";
  10. if (!query.exec(str)) {
  11. qDebug() << "Unable to create table";
  12. }else{
  13. qDebug() << "create user table";
  14. }
  15. }
  16.  
  17. void CreateAmountTable()
  18. {
  19. QSqlQuery query;
  20. QString str = "CREATE TABLE amount ( "
  21. "id INTEGER PRIMARY KEY NOT NULL, "
  22. "reason VARCHAR(144), "
  23. "summ VARCHAR(144), "
  24. "author INTEGER, "
  25. "FOREIGN KEY(author) REFERENCES user(id)"
  26. ");";
  27. if (!query.exec(str)) {
  28. qDebug() << "Unable to create table";
  29. }else{
  30. qDebug() << "create Amount table";
  31. }
  32. }
  33. void CreateCostsTable()
  34. {
  35. QSqlQuery query;
  36. QString str = "CREATE TABLE costs ( "
  37. "id INTEGER PRIMARY KEY NOT NULL, "
  38. "reason VARCHAR(144), "
  39. "summ VARCHAR(144) "
  40. "author INTEGER, "
  41. "FOREIGN KEY(author) REFERENCES user(id)"
  42. ");";
  43. if (!query.exec(str)) {
  44. qDebug() << "Unable to create table";
  45. }else{
  46. qDebug() << "create cost table";
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement