DB
å¶ç´ã®è¨å®ããããã®ã®ããã¹ããã¼ã¿ã®æå ¥æ®µéã§insertãé»æ¢ãã¦ããéªéãªforeign keyã«æ©ã¾ãããã®ã§ãä¸æçã«åç §æ´åæ§ã®å¶ç´ãåé¤ãã¾ãã ç°å¢ MySQL 5.6 æé ã¾ãã¯ããã¼ãã«ã«è¨å®ããã¦ããåç §å¶ç´ã確èªãã¾ãããã mysql> SHOW CREATEâ¦
æ¯åã°ã°ãã®ãé¢åãªã®ã§ã¡ã¢ã ã¦ã¼ã¶ã¼ã®ä½æ /* æ½è±¡ä¾ */ CREATE USER some_user@some_host IDENTIFIED BY 'some_password'; /* å ·ä½ä¾ */ CREATE USER hoge@localhost IDENTIFIED BY 'hogehoge'; 権éã®ä»ä¸ /* æ½è±¡ä¾ */ GRANT ALL PRIVILEGES ON somâ¦
ä½åº¦ãã°ã°ã£ã¦ããã®ã§ã alter table some_table add unique (some_field); ã¡ãªã¿ã«ãè¤æ°ã®ãã£ã¼ã«ãã®çµã¿åããã§éè¤é¤å»ãããå ´åã¯ä»¥ä¸ã alter table some_table add unique (some_field1, some_field2); åè MySQL ã§å¾ããã¦ãã¼ã¯ã¤ã³ããã¯â¦
PyMySQL3ã使ã£ã¦DBå ã®ãã¼ã¿åå¾ãããã¨ãããvarcharåã«è¨å®ãããã«ã©ã ã®ãã¼ã¿ãbytesåã§è¿ã£ã¦ãã¦ãã¾ãåé¡ã«ééã å¾ã ã®ããã¡ã¢ã ç°å¢ Python 3.4.3 MySQL 5.6 PyMySQL3 解決ç PyMySQL3ã¸ã®æ¥ç¶ã¨ã¯ã¨ãªã¯ä»¥ä¸ã®ãããªå¹³å¡ãªãã®ã§ããã â¦
ã¾ãå¼ã£ããããããªã®ã§ã¡ã¢ã ç°å¢ Python 3.4.3 sqlite3 解決ç executeã¡ã½ããã§SQLãå®è¡ãããã¨ããã¨ããã sqlite3.ProgrammingError: Incorrect number of bindings supplied. ã¨æããã¦ãã¾ãã¾ããã åå ã¯åç´ã§ãexecuteã¡ã½ããã®ç¬¬äºå¼â¦
ãã«ã¹ã¿ãã¯ã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã ã¨èªåã§ãã£ã¦ããã¾ãããå°è¦æ¨¡ãã¬ã¼ã ã¯ã¼ã¯ã ã¨èªåã§ãããã°ãªããªãããã¡ã¢ã CREATE TABLE some_tabel ( `id` INT(11) NOT NULL AUTO_INCREMENT, `created` DATETIME NOT NULL DEFAULT CURRENTâ¦
æ®æ®µMySQLã°ãã使ã£ã¦ãã¦å°ã æ¸æã£ãã®ã§è»½ãã¡ã¢ã ãã¼ã«ã«ã®SQLite3ãç¨ãããã¼ã¿ãã¼ã¹ãéã sqlite3 some.sqlite ãã¼ãã«ã®ä¸è¦§ã表示 $ .tables å ¨ã¦ã®ãã¼ãã«ã®ã¹ãã¼ãã表示 .schema ä¸é¨ã®ãã¼ãã«ã®ã¹ãã¼ãã表示 .schema some_table SQLâ¦
ãã¹ããã¼ã¿ãããå æ¸ã«å ¥ãã¦ãã¾ã£ã¦å¾æãããã¨ãããã¾ãããã ALTER TABLE table_name AUTO_INCREMENT = 1; ããã ãã§ãªã¼ãã¤ã³ã¯ãªã¡ã³ããåæååºæ¥ã¾ãï¼ç´ æ´ãããï¼ï¼
é »ç¹ãªè¨æ¶é害ã«å¯¾å¦ããããã¡ã¢ãMySQLã§ç¹å®ã®ãã¼ã¿ãã¼ã¹ãdumpããã«ã¯ã mysqldump -u ã¦ã¼ã¶å dumpããDBå -p > dumpçµæãã¡ã¤ã«å.sql ãã®ã³ãã³ããå©ãã°è¯ãã ãã¹ã¯ã¼ããè¨å®ãã¦ããªãå ´åã-pãªãã·ã§ã³ã¯ä¸è¦ãä¸è¨ã¯DBã®ä¸èº«ãåºåâ¦
æ¯åå¿ãã¦ãã¾ãããã¡ã¢ãMySQLã®ã¤ã³ã¹ãã¼ã«å¾ã mysql -u root ã§ãã°ã¤ã³ãããã¨ããã¨ã ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ã¨è¨ããçºçãçºçè ã¯ãã¦ãããMySQLã¯5.6ããï¼ï¼ï¼åæãã¹ã¯ã¼â¦