Created
May 11, 2015 16:37
-
-
Save Code-Hex/a6063c3d9e7899f15bb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use DBI; | |
use Teng; | |
use Teng::Schema::Loader; | |
use Data::Dumper; | |
my $dbh = DBI->connect('dbi:SQLite:quickstart.sqlite','','',{ | |
RaiseError => 1, | |
PrintError => 0, | |
AutoCommit => 1, | |
sqlite_unicode => 1, | |
}); | |
my $teng = Teng::Schema::Loader->load( | |
dbh => $dbh, | |
namespace => 'MyApp::DB', | |
); | |
my $row = $teng->insert(user => { | |
id => 1, | |
name => "my wife", | |
age => 23, | |
}); | |
warn Dumper $row->get_columns; | |
my $last_insert_id = $teng->fast_insert(user => { | |
id => 2, | |
name => "my jony", | |
age => 18, | |
}); | |
warn $last_insert_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
perl insert_id.pl
$ sqlite3 quickstart.sqlite
sqlite> .table
user
sqlite> SELECT * FROM user;
1|my wife|23
2|my jony|18