Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created May 11, 2015 16:37
Show Gist options
  • Save Code-Hex/a6063c3d9e7899f15bb1 to your computer and use it in GitHub Desktop.
Save Code-Hex/a6063c3d9e7899f15bb1 to your computer and use it in GitHub Desktop.
#!/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;
@Code-Hex
Copy link
Author

perl insert_id.pl
$ sqlite3 quickstart.sqlite
sqlite> .table
user
sqlite> SELECT * FROM user;
1|my wife|23
2|my jony|18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment