📄 copy_to_psql
字号:
#!/usr/local/bin/perl## $Id: copy_to_psql,v 1.1 2003/04/08 01:25:35 lgfausak Exp $## sc: ser control; tool for maintaining ser's databases## History:# --------# 2003-04-07 initial attempt at file copy script## To-DO:# -----# - generalization for other than mysql databases# - front-end to updating administrative mysql password would# be a convenient thing to have## quick and dirty script to copy 0.8.10 mysql location and subscription table# out and create insert statements for postgres new CVS version table# this script only copies 2 tables, location and subscriber.# you may need to modify the open(FD,"sdfdsf") line to suite your needs.#$q = <<EOT;select user_id, domain, contact, expires, q, callid, cseq, last_modified from locationEOTif(!open(FD,"/usr/local/mysql/bin/mysql --batch ser -e \"$q\"|")){ die("can't open mysql process");}print "/* insert location tuples */\n";print "delete from location;\n";while(<FD>){ chop; ($user_id,$domain,$contact,$expires,$q,$callid,$cseq, $lastmodified)= split("\t"); $i = <<EOT; insert into location ( username, domain, contact, expires, q, callid, cseq, last_modified, replicate, state ) values ( '$user_id', '$domain', '$contact', '$expires', $q, '$callid', $cseq, '$expires', null, null );EOT $i =~ s/\n/ /g; $i =~ s/\t+/ /g; $i =~ s/^\s+//; $i =~ s/\s+$//; print "$i\n";}$q = <<EOT;select phplib_id, user_id, password, first_name, last_name, phone, email_address, datetime_created, datetime_modified, confirmation, flag, sendnotification, greeting, ha1, domain, ha1b, perms, allow_find, timezone from subscriberEOTif(!open(FD,"/usr/local/mysql/bin/mysql --batch ser -e \"$q\"|")){ die("can't open mysql process");}print "/* insert subscriber tuples */\n";print "delete from subscriber;\n";while(<FD>){ chop; ( $phplib_id, $user_id, $password, $first_name, $last_name, $phone, $email_address, $datetime_created, $datetime_modified, $confirmation, $flag, $sendnotification, $greeting, $ha1, $domain, $ha1b, $perms, $allow_find, $timezone) = split("\t"); $i = <<EOT; insert into subscriber ( phplib_id, username, password, first_name, last_name, phone, email_address, datetime_created, datetime_modified, confirmation, flag, sendnotification, greeting, ha1, domain, ha1b, perms, allow_find, timezone ) values ( '$phplib_id', '$user_id', '$password', '$first_name', '$last_name', '$phone', '$email_address', '$datetime_created', '$datetime_created', '$confirmation', '$flag', '$sendnotification', '$greeting', '$ha1', '$domain', '$ha1b', '$perms', '$allow_find', '$timezone' );EOT $i =~ s/\n/ /g; $i =~ s/\t+/ /g; $i =~ s/^\s+//; $i =~ s/\s+$//; print "$i\n";}exit 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -