Skip to content

Instantly share code, notes, and snippets.

@nicomen
Created March 21, 2017 20:01
Show Gist options
  • Save nicomen/19131c991f7f0a6f5eda9b1c0ed66793 to your computer and use it in GitHub Desktop.
Save nicomen/19131c991f7f0a6f5eda9b1c0ed66793 to your computer and use it in GitHub Desktop.
get valid sqlite table and column names for sqlite3
✔ 21:00 ~ $ cat sql_abs.pl
#!/usr/bin/perl
use feature 'say';
use SQL::Abstract;
my $abs = SQL::Abstract->new();
say join ',', $abs->select('my_table', [ 'my_table.my_id' ], { my_id => '1' });
my $abs = SQL::Abstract->new( quote_char => '`' );
say join ',', $abs->select('my_table', [ 'my_table.my_id' ], { my_id => '1' });
✔ 21:00 ~ $ perl sql_abs.pl
SELECT my_table.my_id FROM my_table WHERE ( my_id = ? ),1
SELECT `my_table.my_id` FROM `my_table` WHERE ( `my_id` = ? ),1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment