def _is_initialized(cursor):
"""
Check that database is initialized
"""
cursor.execute('SELECT EXISTS(SELECT 1 FROM '
'information_schema.tables '
'WHERE table_schema = %s '
'AND table_name = %s)',
('public', 'schema_version'))
table_exists = cursor.fetchone()[0]
if not table_exists:
return False
cursor.execute('SELECT * from public.schema_version limit 1')
colnames = [desc[0] for desc in cursor.description]
if colnames != REF_COLUMNS:
raise MalformedSchema(
'Table schema_version has unexpected '
'structure: {struct}'.format(struct='|'.join(colnames)))
return True
评论列表
文章目录