diff --git a/Database.pm b/Database.pm index e613d9d..2f7b35d 100644 --- a/Database.pm +++ b/Database.pm @@ -45,7 +45,7 @@ sub mdo { # Bad hack if ( $name eq 'all' ) { my $q - = 'select id, name, resource, username, comment from passwords'; + = 'select id, name, `group`, resource, username, comment from passwords'; my $sth = $dbh->prepare($q); my $rv = $sth->execute(); @@ -54,19 +54,21 @@ sub mdo { printf "%-11s %-11s %-11s %-11s %-11s\n", colored( "ID", 'white' ), colored( "NAME", 'magenta' ), + colored( "GROUP", 'bold magenta' ), colored( "RESOURCE", 'blue' ), colored( "USERNAME", 'green' ), colored( "COMMENT", 'yellow' ); - print "=================================\n"; - while ( my ( $id, $name, $resource, $username, $comment ) + print "=========================================\n"; + while ( my ( $id, $name, $group, $resource, $username, $comment ) = $sth->fetchrow_array() ) { if ( !defined($comment) ) { $comment = ''; } - printf "%-11s %-11s %-11s %-11s %-11s\n", + printf "%-11s %-11s %-11s %-11s %-11s %-11s\n", colored( $id, 'white' ), colored( $name, 'magenta' ), + colored( $group, 'bold magenta' ), colored( $resource, 'blue' ), colored( $username, 'green' ), colored( $comment, 'yellow' ); @@ -137,8 +139,15 @@ sub create_base { my $dbh = DBI->connect( "dbi:SQLite:dbname=$first_sqlite", "", "" ); print "Create database schema\n"; my $q_table - = "create table passwords(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(32), username VARCHAR(32), - resource TEXT, group VARCHAR(32), password TEXT, comment TEXT)"; + = "CREATE TABLE passwords( + `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + name VARCHAR(32) NOT NULL, + username VARCHAR(32) NOT NULL, + resource TEXT NOT NULL, + password VARCHAR(32) NOT NULL, + comment TEXT NOT NULL, + 'group' VARCHAR(32) NOT NULL + )"; $dbh->do($q_table); print "Encrypt database...\n";