2007-10-01ãã1ã¶æéã®è¨äºä¸è¦§
ç¸å¤ãããã®Railsï¼MySQLã§ãã æ¨æ¥ã¾ã§ã®ã¤ã³ãã¼ãããã«ã©ã ã«æ°å¤åãªãã ãã©ãMySQLã§ã¯Nullã«ãããç¶æ³ããã£ãããããã ãã©ãMySQLã®ã³ãã³ãã ãã§ã¯è§£æ±ºãããã«ãªãã®ã§ãµããµã¨è«¦ããã ããã¸ã§ã¯ã/app/controllers/db_controller.rb #dbâ¦
PostgresããCSVã§åãåºãããã®ãExcelã§å å·¥ãã¦utf8ã«ãã¦MySQLã«åãè¾¼ãã¾ã§ã¯ä¸åºæ¥ã ã£ãããRailsã§ã¯æååããããæç»ãhttp://konohaotoshi.blog69.fc2.com/blog-entry-83.htmlãåèã«ãã¦ãcharasetããæå®ãã¦ã¿ããã©ãç»é²ã¨ãæ¤ç´¢ã¨ãã§â¦
PostgreSQLï¼PHPã§åãã¦ããç°å¢ãRailsï¼MySQLã«å¼è¶ããããã«ããããé å¼µã£ã¦ããããã ã
ãæ軽ãªã¤ã¡ã¼ã¸ããã£ããã©ãå®ã¯é¢åãªCSVã ã£ããããã æåã³ã¼ããããããªããã°ãªããªãï¼ã¨ãã£ã¿ã®æ©è½ãéè¦ï¼ CSVã®æå¾ã®ã«ã©ã ã¯ç©ºç½ã§ãã£ã¦ã¯ãªããªã datetimeã¯NULLã ã 空ç½ãªã¨ãã¯ãå ¨è§ã¹ãã¼ã¹ããå ¥ãã¦ãã å½ããåãªãã ãã¼ãâ¦
åãè¾¼ãCSVãã¡ã¤ã«ã¯Windowsã§ä½æãã¦ããæ¥æ¬èªããªããªã®ãã®ãã¢ã«ãã¡ãããã¨æ°å¤ã ãã®ãµã³ãã«ãä½ã£ã¦åãè¾¼ãã§ã¿ã mysql> load data infile "c:\\users\\username\\documents\\convert_test.csv" into table iftbs fields terminated by ',' eâ¦
ãããå¿ãã¦ãã C:\Aptana IDE Beta\iftb>mysql -u root -p Enter password: ******* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 41 Server version: 5.0.41-community-nt MySQL Community Edition (GPL) Typâ¦
å¿ãã¦ããã・・・ [root@hoge]# su - postgres [postgres@hoge ~]$ psql Welcome to psql VERSION the PostgreSQL ・・・ postgres-# ã㧠postgres-# \q [postgres@hoge ~]$ psql DBname Welcome to ・・・ DBname=#
ã¢ãã¨ã¹ã§ç¤¾å ã®ç¡ç·LANã«æ¥ç¶ããã®ããªãã ãé¢åãªãã ãã©ï½¥ï½¥ï½¥ è¨å®âæ¥ç¶ã¿ãâæ¥ç¶ã¢ã¤ã³ã³â詳細è¨å®ã¿ã ãèªåçã«ä½¿ç¨ããããããã¯ã¼ã¯ãé¸æãã¾ããããããã¯ã¼ã¯ã®é¸æã ããã©ã¤ãã¼ããããã¯ã¼ã¯ã«èªåçã«æ¥ç¶ããããã°ã©ã ã®æ¥ç¶æ¹æ³ãâ¦
ruby script/generate scaffold Iftb Users ã§ã¯ãªãã¦ãæåã§å¿ è¦ãªãã®ãä½æãã C:\Aptana IDE Beta\iftb>ruby script/generate controller Login add_user login log out delete_user list_users exists app/controllers/ exists app/helpers/ create â¦
ã³ãã³ãããã³ããã§è¡ãªã C:\Aptana IDE Beta\iftb>ruby script/generate model User exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/user.rb create test/unit/user_test.rb create test/fixtures/users.yml create db/â¦
db/create.sqlã«ããããæ¸ã drop table if exists users; create table users ( id int not null auto_increment, name varchar(100) not null, hashed_password char(40) null, primary key(id) ); ã³ãã³ãããã³ããã§MySQLãå®è¡ãã C:\Aptana IDE Beâ¦
ãããã¼å¿ãã¦ãã
Railsã§CSVãæ±ãã«ã¯ãfastercsvãã使ãã®ãå®ããã¨ããã話ããã£ã¡ãã£ã¡ã§è¦ã¤ãã¦ãã¤ã³ã¹ãã¼ã«ãã¦ã¿ãã C:\Users\hoge>gem instal fastercsv Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed fastercsv-1â¦