本文整理匯總了Python中gluon.DAL屬性的典型用法代碼示例。如果您正苦於以下問題:Python gluon.DAL屬性的具體用法?Python gluon.DAL怎麽用?Python gluon.DAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類gluon
的用法示例。
在下文中一共展示了gluon.DAL屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _getDal
# 需要導入模塊: import gluon [as 別名]
# 或者: from gluon import DAL [as 別名]
def _getDal(self):
mDal = None
if self.dalPath is not None:
global DAL
sys.path.append(self.dalPath)
mDal = __import__(
'dal', globals={}, locals={}, fromlist=['DAL'], level=0)
DAL = mDal.DAL
return mDal
示例2: instDB
# 需要導入模塊: import gluon [as 別名]
# 或者: from gluon import DAL [as 別名]
def instDB(self, storageFolder, storageConnectionString, autoImport):
self.db = DAL(storageConnectionString, folder=os.path.abspath(
storageFolder), auto_import=autoImport)
return self.db
示例3: copyDB
# 需要導入模塊: import gluon [as 別名]
# 或者: from gluon import DAL [as 別名]
def copyDB(self):
other_db = DAL("%s://%s" % (
self.targetdbType, self.targetdbName), folder=self.targetFolder)
print 'creating tables...'
for table in self.db:
other_db.define_table(
table._tablename, *[field for field in table])
'''
should there be an option to truncAte target DB?
if yes, then change args to allow for choice
and set self.trancate to the art value
if self.truncate==True:
other_db[table._tablename].truncate()
'''
print 'exporting data...'
self.db.export_to_csv_file(open('tmp.sql', 'wb'))
print 'importing data...'
other_db.import_from_csv_file(open_file('tmp.sql', 'rb'))
other_db.commit()
print 'done!'
print 'Attention: do not run this program again or you end up with duplicate records'
示例4: copyDB
# 需要導入模塊: import gluon [as 別名]
# 或者: from gluon import DAL [as 別名]
def copyDB(self):
other_db = DAL("%s://%s" % (
self.targetdbType, self.targetdbName), folder=self.targetFolder)
print 'creating tables...'
for table in self.db:
other_db.define_table(
table._tablename, *[field for field in table])
'''
should there be an option to truncAte target DB?
if yes, then change args to allow for choice
and set self.trancate to the art value
if self.truncate==True:
other_db[table._tablename].truncate()
'''
print 'exporting data...'
self.db.export_to_csv_file(open('tmp.sql', 'wb'))
print 'importing data...'
other_db.import_from_csv_file(open('tmp.sql', 'rb'))
other_db.commit()
print 'done!'
print 'Attention: do not run this program again or you end up with duplicate records'