本文整理汇总了Python中LibCIA.Database.init方法的典型用法代码示例。如果您正苦于以下问题:Python Database.init方法的具体用法?Python Database.init怎么用?Python Database.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibCIA.Database
的用法示例。
在下文中一共展示了Database.init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readStatements
# 需要导入模块: from LibCIA import Database [as 别名]
# 或者: from LibCIA.Database import init [as 别名]
DO NOT use this on a server with important data, as
the database is reinitialized before each trial! Don't
use it on a server running twistd for other purposes,
or an important server of any kind. This program
may eat your pets and cause your toaster to impersonate
former US senators.
usage: regression.py first-rev last-rev output.csv
"""
import sys, os, time, re, xmlrpclib, shutil
import RandomMessage
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database
Database.init({'db': None})
dbcursor = Database.pool.connect().cursor()
def readStatements(filename):
"""Return a sequence of SQL statements from the given file"""
lines = []
for line in open(filename).xreadlines():
line = line.strip()
if not line.startswith("--"):
lines.append(line)
fulltext = " ".join(lines)
for statement in fulltext.split(";"):
statement = statement.strip()
if statement:
yield statement
示例2: Exception
# 需要导入模块: from LibCIA import Database [as 别名]
# 或者: from LibCIA.Database import init [as 别名]
#
# Upgrades a CIA database from version 3 to version 4.
#
# This script must migrate security data to the new format.
# Back up your database before running this, as failure to
# finish could cause all security data to be lost!
#
# -- Micah Dowty
#
import sys, os, time, md5
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database
Database.init()
cursor = Database.pool.connect().cursor()
# Make sure we're starting with version 3
cursor.execute("SELECT value FROM meta WHERE name = 'version'")
if cursor.fetchone()[0] != "3":
raise Exception("This script must only be run on version 3 databases")
# Read in all security data from the old capabilities table...
# Each key gets a list of capabilities, but only one owner.
cursor.execute("SELECT * FROM capabilities")
key_owner = {}
key_ownerMail = {}
key_capabilities = {}
while True:
row = cursor.fetchone()
if row:
示例3: Exception
# 需要导入模块: from LibCIA import Database [as 别名]
# 或者: from LibCIA.Database import init [as 别名]
# sized without stats_messages.
#
# If the conversion takes a while and you want to pick
# up the commits you missed while the conversion was taking
# place, note the ID of the last converted message and add
# a "WHERE id > foo" clause to the stats_messages query.
#
# -- Micah Dowty
#
import sys, os
sys.path[0] = os.path.join(sys.path[0], "..")
from LibCIA import Database, XML
from LibCIA.Stats.Target import StatsTarget
Database.init(serverCursor=True)
cursor = Database.pool.connect().cursor()
# Make sure we're starting with version 3
cursor.execute("SELECT value FROM meta WHERE name = 'version'")
if cursor.fetchall()[0][0] != "6":
raise Exception("This script must only be run on version 6 databases")
# To avoid spending all our time reading buffer headers, cache frequently used targets
targetCache = {}
targetHits = {}
targetCacheMax = 128
rowsProcessed = 0
prevId = 0