当前位置: 首页>>代码示例>>Python>>正文


Python web.database方法代码示例

本文整理汇总了Python中web.database方法的典型用法代码示例。如果您正苦于以下问题:Python web.database方法的具体用法?Python web.database怎么用?Python web.database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在web的用法示例。


在下文中一共展示了web.database方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_dbn

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def get_dbn(cfg_file = "config.cfg"):
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  cn_db_file = os.getenv("CN_DB")
  if cn_db_file is not None:
    #print "*** USING DATABASE", cn_db_file
    cfg_file = cn_db_file
  
  if os.path.exists(cfg_file):
    parser.read(cfg_file)
  else:
    tmp = os.path.dirname(os.path.realpath(__file__))
    parser.read(os.path.join(tmp, cfg_file))

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in " + cfg_file)

  return parser.get(section, 'dbn')

#----------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:cosa-nostra,代码行数:23,代码来源:cn_db.py

示例2: get_dbn

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def get_dbn():
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  parser.read("config.cfg")

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in config.cfg")

  return parser.get(section, 'dbn')

#----------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:14,代码来源:nfp_db.py

示例3: init_web_db

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def init_web_db():
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  parser.read("config.cfg")

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in config.cfg")

  dbn = parser.get(section, 'dbn')

  if dbn == "mysql":
    db = parser.get(section, 'db')
    user = parser.get(section, 'user')
    pw = parser.get(section, 'pw')
    host = parser.get(section, 'host')
    db = web.database(dbn='mysql', db=db, user=user, pw=pw, host=host)
    
    db.query('SET NAMES utf8;')
    db.query('SET CHARACTER SET utf8;')
    db.query('SET character_set_connection=utf8;')
  elif dbn == "sqlite":
    dbname = parser.get(section, 'db')
    db = web.database(dbn='sqlite', db=dbname)
    
    # We need to mimic some MySQL functions in order to be able to use
    # SQLite or use different SQL commands for each database server. I
    # prefer the 1st option, naturally...
    db._db_cursor().connection.create_function("concat", 2, sqlite_concat)
    db._db_cursor().connection.create_function("conv", 3, sqlite_conv)
    db._db_cursor().connection.create_function("instr", 2, sqlite_instr)
    db._db_cursor().connection.create_function("rand", 0, sqlite_rand)

  return db

#----------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:38,代码来源:nfp_db.py

示例4: get_dbn

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def get_dbn(cfg_file="config.cfg"):
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  parser.read(cfg_file)

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in %s" % cfg_file)

  return parser.get(section, 'dbn')

#------------------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:maltindex,代码行数:14,代码来源:web_db.py

示例5: init_web_db

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def init_web_db(cfg_file="config.cfg"):
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  parser.read(cfg_file)

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in %s" % cfg_file)

  dbn = parser.get(section, 'dbn')

  if dbn == "mysql":
    db = parser.get(section, 'db')
    user = parser.get(section, 'user')
    pw = parser.get(section, 'pw')
    host = parser.get(section, 'host')
    db = web.database(dbn='mysql', db=db, user=user, pw=pw, host=host)
    
    db.query('SET NAMES utf8;')
    db.query('SET CHARACTER SET utf8;')
    db.query('SET character_set_connection=utf8;')
  elif dbn == "sqlite":
    dbname = parser.get(section, 'db')
    db = web.database(dbn='sqlite', db=dbname)
    
    # We need to mimic some MySQL functions in order to be able to use
    # SQLite or use different SQL commands for each database server. I
    # prefer the 1st option, naturally...
    db._db_cursor().connection.create_function("concat", 2, sqlite_concat)
    db._db_cursor().connection.create_function("conv", 3, sqlite_conv)
    db._db_cursor().connection.create_function("instr", 2, sqlite_instr)
    db._db_cursor().connection.create_function("rand", 0, sqlite_rand)

  db._db_cursor().connection.text_factory = str

  return db

#------------------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:maltindex,代码行数:40,代码来源:web_db.py

示例6: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def GET(self):
        try:
            if 'user' in session:
                domains = db.query('SELECT * FROM DDNS WHERE user_id=$user_id',
                       vars={'user_id': session.user['ID']})
                return render.ddns(domains, DDNSIndex.ddns_add_form())
            else:
                web.seeother('/login')
        except Exception as e:
            flash('error', 'Please update the database schema. See README for details.')
            web.debug(traceback.print_exc())
            raise web.seeother('/') 
开发者ID:ab77,项目名称:netflix-proxy,代码行数:14,代码来源:auth.py

示例7: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def GET(self):
        pmd = self.get_phpmyadmin_dir();
        web.ctx.session.phpmyadminDir = False
        if pmd: 
            web.ctx.session.phpmyadminDir = 'http://' + web.ctx.host.split(':')[0] + ':'+ pmd[1] + '/' + pmd[0];
        
        data = {}
        data['isSetup'] = True;
        data['mysql_root'] = public.M('config').where('id=?',(1,)).getField('mysql_root');
        data['lan'] = public.getLan('database')
        if os.path.exists(web.ctx.session.setupPath+'/mysql') == False: data['isSetup'] = False;
        return render.database(data) 
开发者ID:NNBBXX,项目名称:BaoTa-Panel,代码行数:14,代码来源:main.py

示例8: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def POST(self):
        import database
        databaseObject = database.database()
        defs = ('GetSlowLogs','GetRunStatus','SetDbConf','GetDbStatus','BinLog','GetErrorLog','GetMySQLInfo','SetDataDir','SetMySQLPort','AddDatabase','DeleteDatabase','SetupPassword','ResDatabasePassword','ToBackup','DelBackup','InputSql','SyncToDatabases','SyncGetDatabases','GetDatabaseAccess','SetDatabaseAccess')
        return publicObject(databaseObject,defs); 
开发者ID:NNBBXX,项目名称:BaoTa-Panel,代码行数:7,代码来源:main.py

示例9: init_web_db

# 需要导入模块: import web [as 别名]
# 或者: from web import database [as 别名]
def init_web_db(cfg_file = "config.cfg"):
  parser = ConfigParser.SafeConfigParser()
  parser.optionxform = str
  cn_db_file = os.getenv("CN_DB")
  if cn_db_file is not None:
    #print "*** USING DATABASE", cn_db_file
    cfg_file = cn_db_file

  if os.path.exists(cfg_file):
    parser.read(cfg_file)
  else:
    tmp = os.path.dirname(os.path.realpath(__file__))
    parser.read(os.path.join(tmp, cfg_file))

  section = 'database'
  if 'database' not in parser.sections():
    raise Exception("No database section in " + cfg_file)

  dbn = parser.get(section, 'dbn')

  if dbn == "mysql":
    db = parser.get(section, 'db')
    user = parser.get(section, 'user')
    pw = parser.get(section, 'pw')
    host = parser.get(section, 'host')
    db = web.database(dbn='mysql', db=db, user=user, pw=pw, host=host)
    
    db.query('SET NAMES utf8;')
    db.query('SET CHARACTER SET utf8;')
    db.query('SET character_set_connection=utf8;')
  elif dbn == "sqlite":
    dbname = parser.get(section, 'db')
    db = web.database(dbn='sqlite', db=dbname)
    
    # We need to mimic some MySQL functions in order to be able to use
    # SQLite or use different SQL commands for each database server. I
    # prefer the 1st option, naturally...
    db._db_cursor().connection.create_function("concat", 2, sqlite_concat)
    db._db_cursor().connection.create_function("conv", 3, sqlite_conv)
    db._db_cursor().connection.create_function("instr", 2, sqlite_instr)
    db._db_cursor().connection.create_function("rand", 0, sqlite_rand)

  return db

#----------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:cosa-nostra,代码行数:47,代码来源:cn_db.py


注:本文中的web.database方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。