В словаре элементы в несортированном виде

master
Бородин Роман 2019-01-17 11:36:12 +03:00
parent c280ab3d63
commit c9741cca05
1 changed files with 15 additions and 15 deletions

View File

@ -11,22 +11,22 @@ conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
def create_schema():
cur = conn.cursor()
d = {
lybcfg.pwd_table_name: lybtools.AUTH_SCHEMA,
lybcfg.sess_table_name: lybtools.SESS_SCHEMA,
lybcfg.cat_table_name: lybtools.CAT_SCHEMA,
lybcfg.doc_table_name: lybtools.DOC_SCHEMA,
lybcfg.bin_table_name: lybtools.BIN_SCHEMA,
lybcfg.docbin_table_name: lybtools.DOCBIN_SCHEMA,
lybcfg.grpcat_access_table: lybtools.GRPCAT_ACCESS_SCHEMA,
lybcfg.grpdoc_access_table: lybtools.GRPDOC_ACCESS_SCHEMA,
lybcfg.pwdcat_access_table: lybtools.PWDCAT_ACCESS_SCHEMA,
lybcfg.pwddoc_access_table: lybtools.PWDDOC_ACCESS_SCHEMA
}
for k in d.keys():
l = [
(lybcfg.pwd_table_name, lybtools.AUTH_SCHEMA),
(lybcfg.sess_table_name, lybtools.SESS_SCHEMA),
(lybcfg.cat_table_name, lybtools.CAT_SCHEMA),
(lybcfg.doc_table_name, lybtools.DOC_SCHEMA),
(lybcfg.bin_table_name, lybtools.BIN_SCHEMA),
(lybcfg.docbin_table_name, lybtools.DOCBIN_SCHEMA),
(lybcfg.grpcat_access_table, lybtools.GRPCAT_ACCESS_SCHEMA),
(lybcfg.grpdoc_access_table, lybtools.GRPDOC_ACCESS_SCHEMA),
(lybcfg.pwdcat_access_table, lybtools.PWDCAT_ACCESS_SCHEMA),
(lybcfg.pwddoc_access_table, lybtools.PWDDOC_ACCESS_SCHEMA)
]
for k in l:
try:
cur.execute('SELECT COUNT(*) FROM %s' % k)
cur.execute('SELECT COUNT(*) FROM %s' % k[0])
except:
cur.execute(d[k])
cur.execute(k[1])
conn.commit()