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


Python StatementCursor.tables方法代码示例

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


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

示例1: create_database

# 需要导入模块: from useless.db.midlevel import StatementCursor [as 别名]
# 或者: from useless.db.midlevel.StatementCursor import tables [as 别名]
def create_database(cfg, default_traits):
    dsn = cfg.get_dsn()
    dsn['dbname'] = 'mishmash'
    conn = QuickConn(dsn)
    cmd = StatementCursor(conn, 'create_database')
    for table in cmd.tables():
        cmd.execute('drop table %s' %table)
    start_schema(conn, default_traits)
    make_suites(conn)
    cmd.execute(grant_public(cmd.tables()))
    cmd.execute(grant_public(['current_environment'], 'ALL'))
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:13,代码来源:paellascheme.py

示例2: _connect

# 需要导入模块: from useless.db.midlevel import StatementCursor [as 别名]
# 或者: from useless.db.midlevel.StatementCursor import tables [as 别名]
 def _connect(self, dbname):
     if self.connections.has_key(dbname):
         dialogs.Message('connection already exists for %s' % dbname)
     else:
         conn = BaseConnection(user=self._dbuser, host=self._dbhost,
                               dbname=dbname, passwd=self._dbpasswd)
         self.connections[dbname] = conn
         cursor = StatementCursor(self.connections[dbname])
         rows = cursor.tables()
         tables = ScrollCList(rcmenu=self.table_edit_menu)
         tables.set_rows(rows, columns=['table'])
         self.append_page(tables, dbname)
         self.set_current_page(dbname)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:15,代码来源:base.py

示例3: PaellaDatabase

# 需要导入模块: from useless.db.midlevel import StatementCursor [as 别名]
# 或者: from useless.db.midlevel.StatementCursor import tables [as 别名]
class PaellaDatabase(Element):
    def __init__(self, conn, path='/'):
        Element.__init__(self, 'paelladatabase')
        self.conn = conn
        self.stmt = StatementCursor(self.conn)
        self._profile_traits_ = ProfileTrait(self.conn)
        self.path = path
        self.aptsources = AptSourceListElement()
        self.appendChild(self.aptsources)
        if 'apt_sources' in self.stmt.tables():
            for row in self.stmt.select(table='apt_sources', order=['apt_id']):
                element = AptSourceElement(row.apt_id, row.uri, row.dist, row.sections,
                                           row.local_path)
                self.aptsources.appendChild(element)
            self.suites = SuitesElement()
            self.appendChild(self.suites)
            for row in self._suite_rows():
                args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
                element = SuiteElement(*args)
                for suiteapt in self.stmt.select(table='suite_apt_sources', order=['ord'],
                                                 clause=Eq('suite', row.suite)):
                    element.appendChild(SuiteAptElement(row.suite,
                                                        suiteapt.apt_id, str(suiteapt.ord)))
                self.suites.appendChild(element)
        else:
            print 'WARNING, apt_sources table does not exist, backing up anyway'
        self.profiles = PaellaProfiles(self.conn)
        self.family = Family(self.conn)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            self.appendChild(TraitsElement(self.conn, suite))

    def _suite_rows(self):
        return self.stmt.select(table='suites', order='suite')

    def write(self, filename):
        path = join(self.path, filename)
        xmlfile = file(path, 'w')
        self.writexml(xmlfile, indent='\t', newl='\n', addindent='\t')

    def backup(self, path=None):
        if path is None:
            path = self.path
        if not isdir(path):
            raise Error, '%s not a directory' % path
        dbfile = file(join(path, 'database.xml'), 'w')
        self.writexml(dbfile, indent='\t', newl='\n', addindent='\t')
        dbfile.close()
        self.backup_profiles(path)
        self.backup_families(path)
        suites = [x.suite for x in self._suite_rows()]
        for suite in suites:
            makepaths(join(path, suite))
            trait = Trait(self.conn, suite)
            for t in trait.get_trait_list():
                trait.set_trait(t)
                trait.export_trait(join(path, suite))

    def backup_profiles(self, path=None):
        profiles_dir = join(path, 'profiles')
        makepaths(profiles_dir)
        self.profiles.export_profiles(profiles_dir)

    def backup_families(self, path=None):
        fpath = join(path, 'families')
        makepaths(fpath)
        self.family.export_families(fpath)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:69,代码来源:main.py

示例4: execute

# 需要导入模块: from useless.db.midlevel import StatementCursor [as 别名]
# 或者: from useless.db.midlevel.StatementCursor import tables [as 别名]
    execute(grant_public(tables))
    execute(grant_group('ALL', sequences, group))
    execute(grant_group('ALL', [t().name for t in full], group))
    execute(grant_group('INSERT', [t().name for t in ins + insup], group))
    execute(grant_group('UPDATE', [t().name for t in insup], group))
    for status in TR_STATUS:
        cursor.insert(table='trouble_status', data=dict(status=status))
        
    
    
    
if __name__ == '__main__':
    import os
    from useless.db.lowlevel import BasicConnection
    from useless.db.midlevel import StatementCursor
    from useless.base.config import Configuration
    from konsultant.base.config import BaseConfig
    from konsultant.db import BaseDatabase
    cfg = Configuration('database', os.path.expanduser('~/.kde/share/config/konsultantrc'))
    dbname = cfg['dbname']
    dbhost = cfg['dbhost']
    dbuser = cfg['dbuser']
    conn = BasicConnection(dbuser, dbhost, dbname)
    #fg = BaseConfig()
    #b = BaseDatabase( cfg , 'schema maker')
    c = StatementCursor(conn)
    if not len(c.tables()):
        create_schema(c, 'konsultant')
        conn.commit()

开发者ID:BackupTheBerlios,项目名称:konsultant-svn,代码行数:31,代码来源:schema.py


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