use DBI
use strict
#use warningsmy $db_instance = "localhost"
my $db_name = "res"
my $db_user = "res"
my $db_pass = "res"#define TITLE_COL 3 #define your movie tittle colum numbermy $dbh = DBI->connect("DBI:ODBC:Driver={SQL Server}Server=$db_instanceDatabase=$db_nameUID=$db_userPWD=$db_pass") or die("\n\nCONNECT ERROR:\n\n$DBI::errstr")my @rows = ()
my $sql = "SELECT * FROM tittle where your_condition_here"
my $sth = $dbh->prepare($sql) or die("\n\nPREPARE ERROR:\n\n$DBI::errstr")
my $em
$sth->execute or die("\n\nQUERY ERROR:\n\n$DBI::errstr")
while(@row = $sth->fetchrow_array())
{
#print @rowprint "\n"
if($row[TITLE_COL] =~ /电影[\d]+/)
{
my @new_row = .....
$sql = "update database title(xxx,yyy,zzz,...) values( join(',', @new_row))"
$sth = $dbh->prepare($sql) or die("\n\nPREPARE ERROR:\n\n$DBI::errstr")
$sth->execute or die("\n\nQUERY ERROR:\n\n$DBI::errstr")
}
}
$dbh->disconnect--------------winxp 下测试通过.
其主要思路是:1.把数据库分解成几个asset文件。2.当需要打开数据库时,如果数据库不存在,就把那几个asset文件重新合并成一个数据库文件。3.如果数据库的版本改变了,就在onUpgrade()方法中把数据库文件删除掉。下面是代码://数据库的缺省路径privatestaticfinalStringDB_PATH="/data/data/com.mypackage.myapp/databases/"privatestaticfinalStringDB_NAME="mydb.db"privatestaticfinalintDB_VERSION=2privatestaticfinalStringDB_SPLIT_NAME="mydb.db.00"privatestaticfinalintDB_SPLIT_COUNT=3privateSQLiteDatabasem_databaseprivatefinalContextm_context/***Constructor*保存传进来的context参数以用来访问应用的asset和资源文件欢迎分享,转载请注明来源:内存溢出
评论列表(0条)