How do I quickly rename a MySQL database (change schema name)?

For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database: RENAME TABLE old_db.table TO new_db.table; You will need to adjust the permissions after that. For scripting in a shell, you can use either of the following: mysql -u username -ppassword old_db -sNe ‘show … Read more

How can I rename a database column in a Ruby on Rails migration?

rename_column :table, :old_column, :new_column You’ll probably want to create a separate migration to do this. (Rename FixColumnName as you will.): script/generate migration FixColumnName # creates db/migrate/xxxxxxxxxx_fix_column_name.rb Then edit the migration to do your will: # db/migrate/xxxxxxxxxx_fix_column_name.rb class FixColumnName < ActiveRecord::Migration def self.up rename_column :table_name, :old_column, :new_column end def self.down # rename back if you need … Read more

Renaming column names in Pandas

RENAME SPECIFIC COLUMNS Use the df.rename() function and refer the columns to be renamed. Not all the columns have to be renamed: df = df.rename(columns={‘oldName1’: ‘newName1’, ‘oldName2’: ‘newName2’}) # Or rename the existing DataFrame (rather than creating a copy) df.rename(columns={‘oldName1’: ‘newName1’, ‘oldName2’: ‘newName2’}, inplace=True) Minimal Code Example df = pd.DataFrame(‘x’, index=range(3), columns=list(‘abcde’)) df a b … Read more

tech