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


Java DatabaseWrapper.execSQL方法代码示例

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


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

示例1: migrate

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
@Override
public void migrate(DatabaseWrapper database) {
    //The column name can't be renamed in sqlite. It is needed create a temporal table with the new column name.
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql=myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql=sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, eventDate, scheduledDate, status, eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:21,代码来源:Migration7RenameEventDate.java

示例2: migrateSurveyTable

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void migrateSurveyTable(DatabaseWrapper database) {
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql=myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql=sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy="INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, creation_date, completion_date, upload_date, scheduled_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:19,代码来源:Migration10RenameTables.java

示例3: migrate

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
@Override
public void migrate(DatabaseWrapper database) {
    String sqlOptionTemp =
            "CREATE TABLE OptionTemp(id_option INTEGER PRIMARY KEY, code TEXT, name TEXT, "
                    + "factor REAL, id_answer_fk INTEGER, id_option_attribute_fk INTEGER)";
    database.execSQL(sqlOptionTemp);

    String sqlCopyOption =
            "INSERT INTO OptionTemp(id_option, code, name, factor, id_answer_fk, "
                    + "id_option_attribute_fk) "
                    + "SELECT id_option, name, code, factor, id_answer_fk, "
                    + "id_option_attribute_fk "
                    + "FROM Option;";
    database.execSQL(sqlCopyOption);

    String sqlDeleteOption = "DROP TABLE Option";
    database.execSQL(sqlDeleteOption);

    String sqlRenameOptionTemp = "ALTER TABLE OptionTemp RENAME TO Option";
    database.execSQL(sqlRenameOptionTemp);
}
 
开发者ID:EyeSeeTea,项目名称:pictureapp,代码行数:22,代码来源:Migration7NameByCode.java

示例4: addProgramToSurvey

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void addProgramToSurvey(DatabaseWrapper database) {
    try {
        //Is possible in some devices between versions the column id_program not exist and it will make a sqliteexception
        addColumn(database, Survey.class, Survey_Table.id_program_fk.getDefinition(), "integer");
        database.execSQL("update survey set id_program = (select id_program from tabgroup where id_tab_group=survey.id_tab_group)");
    } catch (SQLiteException e){
        e.printStackTrace();
        //In the last migration the survey.id_tab_group was renamed to survey.id_program, but here is the fixed value.
        database.execSQL("update survey set id_program = (select id_program from tabgroup where id_tab_group=survey.id_program)");
    }
    //move id_program into survey

}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:14,代码来源:Migration11RemoveTabGroups.java

示例5: recreateTables

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
public static void recreateTables(DatabaseWrapper database,Class[] tables){
    for(int i=0;i<tables.length;i++){
        ModelAdapter myAdapter = FlowManager.getModelAdapter(tables[i]);
        database.execSQL(DROP_TABLE_IF_EXISTS + myAdapter.getTableName());
        database.execSQL(myAdapter.getCreationQuery());
    }
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:8,代码来源:MigrationUtils.java

示例6: migrateServerMetadataTable

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void migrateServerMetadataTable(DatabaseWrapper database) {

        //Insert the data in new table
        String sqlCopy="INSERT INTO ServerMetadata(id_control_dataelement, name, code, uid, value_type) SELECT id_control_dataelement, name, code, uid, valueType FROM ControlDataelement";
        database.execSQL(sqlCopy);

        //Replace old table by new table with the new column name.
        database.execSQL("DROP TABLE IF EXISTS ControlDataelement");
    }
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:10,代码来源:Migration10RenameTables.java

示例7: enable

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
public void enable(@NonNull DatabaseWrapper databaseWrapper) {
    if (table == null) {
        throw new IllegalStateException("Please call on() to set a table to use this index on.");
    } else if (columns == null || columns.isEmpty()) {
        throw new IllegalStateException("There should be at least one column in this index");
    }
    databaseWrapper.execSQL(getQuery());
}
 
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:9,代码来源:Index.java

示例8: dropIndex

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
/**
 * Drops an active INDEX by specifying the databaseWrapper and indexName
 *
 * @param databaseWrapper The manually specified wrapper.
 * @param indexName       The name of the index.
 */
public static void dropIndex(@NonNull DatabaseWrapper databaseWrapper,
                             @NonNull String indexName) {
    QueryBuilder queryBuilder = new QueryBuilder("DROP INDEX IF EXISTS ")
            .append(QueryBuilder.quoteIfNeeded(indexName));
    databaseWrapper.execSQL(queryBuilder.getQuery());
}
 
开发者ID:Raizlabs,项目名称:DBFlow,代码行数:13,代码来源:SqlUtils.java

示例9: addProgramStageToProgram

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void addProgramStageToProgram(DatabaseWrapper database) {
    addColumn(database, Program.class, Program_Table.stage_uid.getDefinition(), "string");
    //move programStage uid into program
    database.execSQL("update program set stage_uid = (select uid from tabgroup where id_program=program.id_program)");
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:6,代码来源:Migration11RemoveTabGroups.java

示例10: addProgramToTab

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void addProgramToTab(DatabaseWrapper database) {
    addColumn(database, Tab.class, Tab_Table.id_program_fk.getDefinition(), "integer");
    //move id_program into tab
    database.execSQL("update tab set id_program = (select id_program from tabgroup where id_tab_group=tab.id_tab_group)");
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:6,代码来源:Migration11RemoveTabGroups.java

示例11: removeTabGroups

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
private void removeTabGroups(DatabaseWrapper database) {
    database.execSQL("DROP TABLE IF EXISTS tabgroup");
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:4,代码来源:Migration11RemoveTabGroups.java

示例12: addColumn

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
public static void addColumn(DatabaseWrapper database, Class model, String columnName, String type){
    ModelAdapter myAdapter = FlowManager.getModelAdapter(model);
    database.execSQL(String.format(ALTER_TABLE_ADD_COLUMN, myAdapter.getTableName(), columnName, type));

}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:6,代码来源:MigrationUtils.java

示例13: updateColumn

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
public static void updateColumn(DatabaseWrapper database, Class model, String columnName,String value){
    ModelAdapter myAdapter = FlowManager.getModelAdapter(model);
    Log.d(TAG, String.format(UPDATE_COLUMN, myAdapter.getTableName(), columnName, value));
    database.execSQL(String.format(UPDATE_COLUMN, myAdapter.getTableName(),columnName,value) );
}
 
开发者ID:EyeSeeTea,项目名称:malariapp,代码行数:6,代码来源:MigrationUtils.java

示例14: migrate

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
@Override
public void migrate(DatabaseWrapper database) {

    String sqlCopy = "INSERT INTO Partner (id_partner, uid_partner, name)"
            + " SELECT id_organisation, uid_organisation, name"
            + " FROM Organisation;";
    database.execSQL(sqlCopy);
    String sqlDelete = "DROP TABLE IF EXISTS Organisation;";
    database.execSQL(sqlDelete);

    String sqlUserTemp =
            "CREATE TABLE UserTemp(id_user INTEGER PRIMARY KEY, uid_user TEXT, name TEXT, "
                    + "partner_fk INTEGER, supervisor_fk INTEGER)";
    database.execSQL(sqlUserTemp);
    String sqlCopyUser =
            "INSERT INTO UserTemp (id_user, uid_user, name, partner_fk, supervisor_fk)"
                    + " SELECT id_user, uid_user, name ,organisation_fk ,supervisor_fk"
                    + " FROM User;";
    database.execSQL(sqlCopyUser);
    String sqlDeleteUser = "DROP TABLE IF EXISTS User;";
    database.execSQL(sqlDeleteUser);
    String renameUser = "ALTER TABLE UserTemp RENAME TO User";
    database.execSQL(renameUser);

    String sqlTreatmentTemp =
            "CREATE TABLE TreatmentTemp(id_treatment INTEGER PRIMARY KEY, "
                    + "id_partner_fk INTEGER, diagnosis INTEGER, message INTEGER, type "
                    + "INTEGER)";
    database.execSQL(sqlTreatmentTemp);
    String sqlCopyTreatment =
            "INSERT INTO TreatmentTemp (id_treatment, id_partner_fk, diagnosis, message, type)"
                    + " SELECT id_treatment, id_organisation_fk, diagnosis, message, type"
                    + " FROM Treatment;";
    database.execSQL(sqlCopyTreatment);
    String sqlDeleteTreatment = "DROP TABLE IF EXISTS Treatment;";
    database.execSQL(sqlDeleteTreatment);
    String renameTreatment = "ALTER TABLE TreatmentTemp RENAME TO Treatment";
    database.execSQL(renameTreatment);

    FileCsvs fileCsvs = new FileCsvs();
    try {
        fileCsvs.copyCsvFile("Organisations.csv", PopulateDB.PARTNER_CSV);
    } catch (IOException e) {
       new MigrateMigrationException(e);
    }
}
 
开发者ID:EyeSeeTea,项目名称:pictureapp,代码行数:47,代码来源:Migration4RenameOrganisationToPartner.java

示例15: addColumn

import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper; //导入方法依赖的package包/类
public static void addColumn(DatabaseWrapper database, Class model, String columnName,
        String type) {
    ModelAdapter myAdapter = FlowManager.getModelAdapter(model);
    database.execSQL(
            String.format(ALTER_TABLE_ADD_COLUMN, myAdapter.getTableName(), columnName, type));
}
 
开发者ID:EyeSeeTea,项目名称:pictureapp,代码行数:7,代码来源:MigrationTools.java


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