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


Python db.execute_many函数代码示例

本文整理汇总了Python中south.db.db.execute_many函数的典型用法代码示例。如果您正苦于以下问题:Python execute_many函数的具体用法?Python execute_many怎么用?Python execute_many使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: forwards

    def forwards(self, orm):
        # Adding model 'AddressRecord'
        db.create_table('address_record', (
            ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
            ('modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
            ('ip_str', self.gf('django.db.models.fields.CharField')(max_length=39)),
            ('ip_upper', self.gf('django.db.models.fields.BigIntegerField')(null=True, blank=True)),
            ('ip_lower', self.gf('django.db.models.fields.BigIntegerField')(null=True, blank=True)),
            ('ip_type', self.gf('django.db.models.fields.CharField')(max_length=1)),
            ('domain', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['domain.Domain'])),
            ('label', self.gf('django.db.models.fields.CharField')(max_length=63, null=True, blank=True)),
            ('fqdn', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=255, null=True, blank=True)),
            ('ttl', self.gf('django.db.models.fields.PositiveIntegerField')(default=3600, null=True, blank=True)),
            ('description', self.gf('django.db.models.fields.CharField')(max_length=1000, null=True, blank=True)),
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
        ))
        db.send_create_signal('address_record', ['AddressRecord'])

        # Adding unique constraint on 'AddressRecord', fields ['label', 'domain', 'fqdn', 'ip_upper', 'ip_lower', 'ip_type']
        db.create_unique('address_record', ['label', 'domain_id', 'fqdn', 'ip_upper', 'ip_lower', 'ip_type'])

        # Adding M2M table for field views on 'AddressRecord'
        db.create_table('address_record_views', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('addressrecord', models.ForeignKey(orm['address_record.addressrecord'], null=False)),
            ('view', models.ForeignKey(orm['view.view'], null=False))
        ))
        db.create_unique('address_record_views', ['addressrecord_id', 'view_id'])
        db.execute_many(open("cyder/cydns/address_record/sql/addressrecord.sql").read())
开发者ID:alecdhuse,项目名称:cyder,代码行数:29,代码来源:0001_initial.py

示例2: forwards

    def forwards(self, orm):
        # Adding model 'PTR'
        db.create_table('ptr', (
            ('ip_str', self.gf('django.db.models.fields.CharField')(max_length=39)),
            ('ip_upper', self.gf('django.db.models.fields.BigIntegerField')(null=True, blank=True)),
            ('ip_lower', self.gf('django.db.models.fields.BigIntegerField')(null=True, blank=True)),
            ('ip_type', self.gf('django.db.models.fields.CharField')(max_length=1)),
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('reverse_domain', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['domain.Domain'], blank=True)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('ttl', self.gf('django.db.models.fields.PositiveIntegerField')(default=3600, null=True, blank=True)),
            ('description', self.gf('django.db.models.fields.CharField')(max_length=1000, null=True, blank=True)),
        ))
        db.send_create_signal('ptr', ['PTR'])

        # Adding unique constraint on 'PTR', fields ['ip_str', 'ip_type', 'name']
        db.create_unique('ptr', ['ip_str', 'ip_type', 'name'])

        # Adding M2M table for field views on 'PTR'
        db.create_table('ptr_views', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('ptr', models.ForeignKey(orm['ptr.ptr'], null=False)),
            ('view', models.ForeignKey(orm['view.view'], null=False))
        ))
        db.create_unique('ptr_views', ['ptr_id', 'view_id'])
        db.execute_many(open("cyder/cydns/ptr/sql/ptr.sql").read())
开发者ID:alecdhuse,项目名称:cyder,代码行数:26,代码来源:0001_initial.py

示例3: forwards

    def forwards(self, orm):
        # Adding model 'Network'
        db.create_table('network', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('vlan', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vlan.Vlan'], null=True, on_delete=models.SET_NULL, blank=True)),
            ('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['site.Site'], null=True, on_delete=models.SET_NULL, blank=True)),
            ('ip_type', self.gf('django.db.models.fields.CharField')(max_length=1)),
            ('ip_upper', self.gf('django.db.models.fields.BigIntegerField')(blank=True)),
            ('ip_lower', self.gf('django.db.models.fields.BigIntegerField')(blank=True)),
            ('network_str', self.gf('django.db.models.fields.CharField')(max_length=49)),
            ('prefixlen', self.gf('django.db.models.fields.PositiveIntegerField')()),
            ('dhcpd_raw_include', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
        ))
        db.send_create_signal('network', ['Network'])

        # Adding unique constraint on 'Network', fields ['ip_upper', 'ip_lower', 'prefixlen']
        db.create_unique('network', ['ip_upper', 'ip_lower', 'prefixlen'])

        # Adding model 'NetworkKeyValue'
        db.create_table('network_kv', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('key', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('value', self.gf('django.db.models.fields.CharField')(max_length=255)),
            ('is_quoted', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('is_option', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('is_statement', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('has_validator', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('network', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['network.Network'])),
        ))
        db.send_create_signal('network', ['NetworkKeyValue'])

        # Adding unique constraint on 'NetworkKeyValue', fields ['key', 'value', 'network']
        db.create_unique('network_kv', ['key', 'value', 'network_id'])
        db.execute_many(open("cyder/cydhcp/network/sql/network.sql").read())
开发者ID:alecdhuse,项目名称:cyder,代码行数:34,代码来源:0001_initial.py

示例4: forwards

    def forwards(self, orm):
        
        db.start_transaction()
        # Argh. The DB dump has a lot of crap we don't care about at all.
 
        # So, use South's fake ORM dictionary to figure out how to create those columns.
        db.add_column('gis_neighborhoods', 'stacked', orm['bmabr.neighborhood:stacked'])
        db.add_column('gis_neighborhoods', 'annoline1', orm['bmabr.neighborhood:annoline1']),
        db.add_column('gis_neighborhoods', 'annoline2', orm['bmabr.neighborhood:annoline2']),
        db.add_column('gis_neighborhoods', 'annoline3', orm['bmabr.neighborhood:annoline3']),
        db.add_column('gis_neighborhoods', 'annoangle', orm['bmabr.neighborhood:annoangle']), 
        db.commit_transaction()

        # Now load the data.
        db.start_transaction()
        HERE = os.path.abspath(os.path.dirname(__file__))
        sql_path = os.path.abspath(
            os.path.join(HERE, '..', '..', 'sql', 'gis_neighborhoods.sql'))
        db.execute_many(open(sql_path).read())
        db.execute("UPDATE gis_neighborhoods SET state = 'NY'")
        db.commit_transaction()

        # Now clean up the crap we don't want.
        db.start_transaction()
        db.delete_column('gis_neighborhoods', 'stacked')
        db.delete_column('gis_neighborhoods', 'annoangle')
        db.delete_column('gis_neighborhoods', 'annoline1')
        db.delete_column('gis_neighborhoods', 'annoline2')
        db.delete_column('gis_neighborhoods', 'annoline3')
        db.commit_transaction()
开发者ID:natea,项目名称:fixcity,代码行数:30,代码来源:0022_populate_hoods.py

示例5: backwards

 def backwards(self, orm):
     db.execute_many('\n'.join(
         "ALTER TABLE {table_name} MODIFY COLUMN {column_name} timestamp NULL;".format(
             table_name=table_name,
             column_name=column_name,
         ) for table_name, column_name in TIMESTAMP_COLUMNS
     ))
开发者ID:edgeflip,项目名称:edgeflip,代码行数:7,代码来源:0005_convert_timestamps_to_datetimes.py

示例6: forwards

 def forwards(self, orm):
     db.delete_foreign_key('fccpublicfiles_politicalbuy', 'publicdocument_ptr_id')
     db.rename_column('fccpublicfiles_politicalbuy', 'publicdocument_ptr_id', 'id')
     db.execute_many('''
         create sequence fccpublicfiles_politicalbuy_id_seq;
         select setval('fccpublicfiles_politicalbuy_id_seq', max(id)) from fccpublicfiles_publicdocument;
         alter table fccpublicfiles_politicalbuy alter column id set default nextval('fccpublicfiles_politicalbuy_id_seq');
     ''')
开发者ID:dwillis,项目名称:fcc_political_ads,代码行数:8,代码来源:0008_reconfigure_pk_on_politicalbuy.py

示例7: forwards

 def forwards(self, orm):
     curdir = os.path.dirname(os.path.abspath(__file__))
     sqldir = os.path.normpath(os.path.join(curdir, '..', '..', 'sql'))
     cityracks_path = os.path.join(sqldir, 'gis_cityracks.sql')
     f = open(cityracks_path)
     sql = f.read()
     f.close()
     db.execute_many(sql)
开发者ID:natea,项目名称:fixcity,代码行数:8,代码来源:0017_add_cityracks.py

示例8: forwards

 def forwards(self, orm):
     if db.backend_name == 'mysql':
         db.execute_many("""
         ALTER DATABASE CHARACTER SET utf8 COLLATE utf8_general_ci;
         ALTER TABLE student_pendingemailchange CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
         ALTER TABLE student_pendingnamechange CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
         ALTER TABLE student_usertestgroup CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
         ALTER TABLE student_usertestgroup_users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
         """)
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:9,代码来源:0007_convert_to_utf8.py

示例9: forwards

    def forwards(self, orm):
        basepath = os.path.dirname(os.path.dirname(__file__))
        configsql = os.path.join(basepath, 'sql', 'configsection.sql')
        signaturesql = os.path.join(basepath, 'sql', 'domainsignature.sql')

        # configsection.sql
        db.execute_many(open(configsql).read())

        # domainsignature.sql
        db.execute_many(open(signaturesql).read())
开发者ID:haugvald,项目名称:baruwa,代码行数:10,代码来源:0003_initial_sql.py

示例10: forwards

 def forwards(self, orm):
     
     # Adding model 'NYCStreet'
     sql_path = os.path.abspath(
         os.path.join(HERE, '..', '..', 'data', 'shps', 'nyc_streets',
                      'gis_nycstreets.sql.gz'))
     import gzip
     z = gzip.GzipFile(sql_path)
     db.execute_many(z.read())
     db.send_create_signal('bmabr', ['NYCStreet'])
开发者ID:natea,项目名称:fixcity,代码行数:10,代码来源:0019_add_nycstreets.py

示例11: forwards

 def forwards(self, orm):
     SQLDIR = os.path.join(os.path.dirname(__file__),'..','sql')
     print "Sql directory: '%s'" % SQLDIR
     sqlfile = os.path.join(SQLDIR,'dbviews-mysql.sql')
     print "Sql file: '%s'" % sqlfile
     sql = open(sqlfile).read()
     print "Sql to execute: views: %s  lines: %s" % (sql.count('create or replace view'),  sql.count('\n'))
     db.execute_many(sql)
     #db.execute_many(sql, regex=r"(?mx) ([^';]* (?:'[^']*'[^';]*)*)", comment_regex=r"(?mx) (?:^\s*$)|(?:--.*$)") #remove comments        
     print "Sql executed!"
开发者ID:tximikel,项目名称:timebank,代码行数:10,代码来源:0001_initial.py

示例12: forwards

 def forwards(self, orm):
     "Make Course.id == Course.number"
     sql = """
         SET CONSTRAINTS ALL DEFERRED;
         UPDATE "courses_coursemark" SET "course_id"="number" 
           FROM "courses_course" 
           WHERE "courses_course"."id" = "course_id";
         UPDATE "courses_course" SET "id"="number";
     """
     db.execute_many(sql)
开发者ID:imclab,项目名称:yachter,代码行数:10,代码来源:0002_migrate_course_number_to_id.py

示例13: forwards

 def forwards(self, orm):
     "Write your forwards methods here."
     # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
     db.execute_many("""
     update fccpublicfiles_genericpublicdocument set is_visible = 't'; 
     update fccpublicfiles_politicalbuy set is_visible = 't'; 
     update fccpublicfiles_organization set is_visible = 't'; 
     update fccpublicfiles_politicalspot set is_visible = 't'; 
     update fccpublicfiles_role set is_visible = 't'; 
     update fccpublicfiles_person set is_visible = 't'; 
     """)
开发者ID:dwillis,项目名称:fcc_political_ads,代码行数:11,代码来源:0014_set_is_visible_true.py

示例14: backwards

    def backwards(self, orm):
        # Adding field 'Domain.forward_canonical'
        db.add_column('domain', 'forward_canonical', orm['domain.domain:forward_canonical'])

        # Adding field 'Domain.alias'
        db.add_column('domain', 'alias', orm['domain.domain:alias'])

        # Adding field 'Domain.is_active'
        db.add_column('domain', 'is_active', orm['domain.domain:is_active'])

        # replace with original view
        db.execute_many(DB_VIEWS_BACKWARDS)
开发者ID:hollow,项目名称:nepal,代码行数:12,代码来源:0004_remove_migrated_columns.py

示例15: forwards

    def forwards(self, orm):
        
        #This is also done in a custom manner to workwith the latin1 varchar country foreign key
        #like im migration 0007
        db.execute_many("""
        CREATE TABLE `sqp_questionbulkassignments_users` (
            `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
            `questionbulkassignments_id` integer NOT NULL,
            `user_id` integer NOT NULL,
            UNIQUE (`questionbulkassignments_id`, `user_id`)
        ) ENGINE = InnoDB DEFAULT CHARSET = latin1;
        
        ALTER TABLE `sqp_questionbulkassignments_users` ADD CONSTRAINT `user_id_refs_id_
        178ee5d9` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
        """)
        
        db.execute("""
        CREATE TABLE `sqp_questionbulkassignments` (
            `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
            `study_id` integer NULL,
            `country_id` varchar(2) NULL,
            `language_id` integer NULL,
            `can_edit_text` bool NOT NULL,
            `can_edit_details` bool NOT NULL,
            `run_on_save` bool NOT NULL,
            `has_been_run` bool NOT NULL,
            `last_run_date` date NULL
        ) ENGINE = InnoDB DEFAULT CHARSET = latin1;
        """)
        
        db.execute("""
        ALTER TABLE `sqp_questionbulkassignments` ADD CONSTRAINT `country_id_refs_iso_64c7b67d` 
        FOREIGN KEY (`country_id`) REFERENCES `sqp_country` (`iso`);
        """)
        
        db.execute("""
        ALTER TABLE `sqp_questionbulkassignments` ADD CONSTRAINT `language_id_refs_id_7797b23c`
        FOREIGN KEY (`language_id`) REFERENCES `sqp_language` (`id`);
        """)
        
        db.execute("""
        ALTER TABLE `sqp_questionbulkassignments_users` ADD CONSTRAINT `questionbulkassignments_id_refs_id_32707ecc`
         FOREIGN KEY (`questionbulkassignments_id`) REFERENCES 
         `sqp_questionbulkassignments` (`id`);
        """)

        db.send_create_signal('sqp', ['QuestionBulkAssignments'])
        
        # Changing field 'UserProfile.user'
        db.alter_column('sqp_userprofile', 'user_id', self.gf('django.db.models.fields.related.OneToOneField')(unique=True, to=orm['auth.User']))

        # Adding unique constraint on 'UserProfile', fields ['user']
        db.create_unique('sqp_userprofile', ['user_id'])
开发者ID:recsm,项目名称:SQP,代码行数:53,代码来源:0017_auto__add_questionbulkassignments__chg_field_userprofile_user__add_uni.py


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