File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ class CLISessionDatabaseConnection:
6666 id TEXT UNIQUE NOT NULL
6767 )
6868 """
69+ _CHECK_HOST_ID = """
70+ SELECT COUNT(*) FROM host_id
71+ """
6972 _INSERT_HOST_ID = """
7073 INSERT OR IGNORE INTO host_id (
7174 key, id
@@ -107,15 +110,18 @@ def _create_host_id_table(self):
107110 self .execute (self ._CREATE_HOST_ID_TABLE )
108111
109112 def _ensure_host_id (self ):
110- self .execute (
111- self ._INSERT_HOST_ID ,
112- # Hardcode `0` as primary key to ensure
113- # there's only ever 1 host id in the table.
114- (
115- 0 ,
116- str (uuid .uuid4 ()),
117- ),
118- )
113+ cur = self .execute (self ._CHECK_HOST_ID )
114+ host_id_ct = cur .fetchone ()[0 ]
115+ if host_id_ct == 0 :
116+ self .execute (
117+ self ._INSERT_HOST_ID ,
118+ # Hardcode `0` as primary key to ensure
119+ # there's only ever 1 host id in the table.
120+ (
121+ 0 ,
122+ str (uuid .uuid4 ()),
123+ ),
124+ )
119125
120126 def _try_to_enable_wal (self ):
121127 try :
You can’t perform that action at this time.
0 commit comments