def get_dbhandle(dbname,flag=True): """获取数据库操作句柄 flag 只读标识 True选择数据库读库,False写库 """ dbinfo = sconf.get_db_info(dbname,flag) dbinfo['info']['dbname']=dbinfo['dbname'] db = dbclass(dbinfo['info']) res,desc = db.connect() if res == -1: return on_sql_error(desc) return db
def check_shard_table(db,dbname,table,id=0): """判断是表否分拆 """ dbinf = sconf.get_db_info(dbname,True) shard_table = dbinf['shard_table'].keys() if dbname in shard_table: if not id: id = get_table_id(tabe,db) table = get_table_name(id,tabe) return table