Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. Index: plugins_base/Logger.py
  2. ===================================================================
  3. --- plugins_base/Logger.py (revision 1466)
  4. +++ plugins_base/Logger.py (working copy)
  5. @@ -49,7 +49,7 @@
  6. or similar'''
  7.  
  8. CREATE_USER = '''
  9. - CREATE TABLE user
  10. + CREATE TABLE IF NOT EXISTS user
  11. (
  12. id INTEGER PRIMARY KEY,
  13. account TEXT
  14. @@ -57,7 +57,7 @@
  15. '''
  16.  
  17. CREATE_CONVERSATION = '''
  18. - CREATE TABLE conversation
  19. + CREATE TABLE IF NOT EXISTS conversation
  20. (
  21. id INTEGER PRIMARY KEY,
  22. started INTEGER
  23. @@ -65,7 +65,7 @@
  24. '''
  25.  
  26. CREATE_EVENT = '''
  27. - CREATE TABLE event
  28. + CREATE TABLE IF NOT EXISTS event
  29. (
  30. id INTEGER PRIMARY KEY,
  31. stamp INTEGER,
  32. @@ -74,7 +74,7 @@
  33. '''
  34.  
  35. CREATE_USER_EVENT = '''
  36. - CREATE TABLE user_event
  37. + CREATE TABLE IF NOT EXISTS user_event
  38. (
  39. id_event INTEGER,
  40. id_user INTEGER,
  41. @@ -83,7 +83,7 @@
  42. '''
  43.  
  44. CREATE_CONVERSATION_EVENT = '''
  45. - CREATE TABLE conversation_event
  46. + CREATE TABLE IF NOT EXISTS conversation_event
  47. (
  48. id_event INTEGER,
  49. id_conversation INTEGER,
  50. @@ -91,9 +91,9 @@
  51. data TEXT
  52. )
  53. '''
  54. - CREATE_USER_EVENT_INDEX_EVENT = 'CREATE INDEX ueidevent ON \
  55. + CREATE_USER_EVENT_INDEX_EVENT = 'CREATE INDEX IF NOT EXISTS ueidevent ON \
  56. user_event(id_event)'
  57. - CREATE_USER_EVENT_INDEX_USER = 'CREATE INDEX ueiduser ON \
  58. + CREATE_USER_EVENT_INDEX_USER = 'CREATE INDEX IF NOT EXISTS ueiduser ON \
  59. user_event(id_user)'
  60.  
  61. USER_EXISTS = 'SELECT id FROM user WHERE account = ?'
  62. @@ -111,9 +111,6 @@
  63. CONVERSATION_ADD = 'INSERT INTO conversation(id, started) \
  64. VALUES(null, ?)'
  65.  
  66. - CHECK_AVAIL_INDEX = 'CREATE INDEX IF NOT EXISTS ueiduser \
  67. - ON user_event(id_user);'
  68. -
  69. def __init__(self, path):
  70. '''constructor, try to open the database at path, if can not open
  71. it, then try to create it'''
  72. @@ -138,7 +135,6 @@
  73. self.cursor.execute(Logger.CREATE_CONVERSATION)
  74. self.cursor.execute(Logger.CREATE_EVENT)
  75. self.cursor.execute(Logger.CREATE_USER_EVENT)
  76. - self.cursor.execute(Logger.CHECK_AVAIL_INDEX)
  77. self.cursor.execute(Logger.CREATE_USER_EVENT_INDEX_EVENT)
  78. self.cursor.execute(Logger.CREATE_USER_EVENT_INDEX_USER)
  79. self.cursor.execute(Logger.CREATE_CONVERSATION_EVENT)
Add Comment
Please, Sign In to add comment