pragma table_info return column delimiters?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

pragma table_info return column delimiters?

Bart Smissaert
Is there a way with pragma table_info or otherwise (other than parsing the
table create statement from SQLite_master) to get the column names
including the column delimiters, eg double quotes or square brackets? So I
would get eg: [column1] [column2] etc. if indeed the column names were
delimited like that.

RBS
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

Luuk


On 03-01-18 11:15, Bart Smissaert wrote:
> Is there a way with pragma table_info or otherwise (other than parsing the
> table create statement from SQLite_master) to get the column names
> including the column delimiters, eg double quotes or square brackets? So I
> would get eg: [column1] [column2] etc. if indeed the column names were
> delimited like that.
>
> RBS
>
What are column delimiters?

|sqlite> select * from test;
a, b, c
1, 2, drie
4, 5, zes
sqlite> select a,b,c from test;
a, b, c
1, 2, drie
4, 5, zes
sqlite> select [a],[b],[c] from test;
a, b, c
1, 2, drie
4, 5, zes
sqlite> select "a","b","c" from test;
a, b, c
1, 2, drie
4, 5, zes

Of course, you shoul not use single quotes ;)
sqlite> select 'a','b','c' from test;
'a', 'b', 'c'
a, b, c
a, b, c
sqlite>|
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

Bart Smissaert
> What are column delimiters?

create table [table1)([ID] integer, [text_field] text)

I am talking about the square brackets here surrounding the field names.
Sorry, used the wrong word in saying delimiters.

RBS

On Wed, Jan 3, 2018 at 10:44 AM, Luuk <[hidden email]> wrote:

>
>
> On 03-01-18 11:15, Bart Smissaert wrote:
> > Is there a way with pragma table_info or otherwise (other than parsing
> the
> > table create statement from SQLite_master) to get the column names
> > including the column delimiters, eg double quotes or square brackets? So
> I
> > would get eg: [column1] [column2] etc. if indeed the column names were
> > delimited like that.
> >
> > RBS
> >
> What are column delimiters?
>
> |sqlite> select * from test;
> a, b, c
> 1, 2, drie
> 4, 5, zes
> sqlite> select a,b,c from test;
> a, b, c
> 1, 2, drie
> 4, 5, zes
> sqlite> select [a],[b],[c] from test;
> a, b, c
> 1, 2, drie
> 4, 5, zes
> sqlite> select "a","b","c" from test;
> a, b, c
> 1, 2, drie
> 4, 5, zes
>
> Of course, you shoul not use single quotes ;)
> sqlite> select 'a','b','c' from test;
> 'a', 'b', 'c'
> a, b, c
> a, b, c
> sqlite>|
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

Richard Hipp-3
In reply to this post by Bart Smissaert
On 1/3/18, Bart Smissaert <[hidden email]> wrote:
> Is there a way with pragma table_info or otherwise (other than parsing the
> table create statement from SQLite_master) to get the column names
> including the column delimiters, eg double quotes or square brackets? So I
> would get eg: [column1] [column2] etc. if indeed the column names were
> delimited like that.

No.  SQLite does not retain that information in its internal symbol
tables.  You'll have to parse out the original CREATE TABLE statements
to figure that out.
--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

J Decker
In reply to this post by Bart Smissaert
delimiters delimit, so they are not part of the context.. such information
aobut delimiters is never saved... since they havce done their job
delimiiting already.

Why do you want this?


On Wed, Jan 3, 2018 at 2:50 AM, Bart Smissaert <[hidden email]>
wrote:

> > What are column delimiters?
>
> create table [table1)([ID] integer, [text_field] text)
>
> I am talking about the square brackets here surrounding the field names.
> Sorry, used the wrong word in saying delimiters.
>
> RBS
>
> On Wed, Jan 3, 2018 at 10:44 AM, Luuk <[hidden email]> wrote:
>
> >
> >
> > On 03-01-18 11:15, Bart Smissaert wrote:
> > > Is there a way with pragma table_info or otherwise (other than parsing
> > the
> > > table create statement from SQLite_master) to get the column names
> > > including the column delimiters, eg double quotes or square brackets?
> So
> > I
> > > would get eg: [column1] [column2] etc. if indeed the column names were
> > > delimited like that.
> > >
> > > RBS
> > >
> > What are column delimiters?
> >
> > |sqlite> select * from test;
> > a, b, c
> > 1, 2, drie
> > 4, 5, zes
> > sqlite> select a,b,c from test;
> > a, b, c
> > 1, 2, drie
> > 4, 5, zes
> > sqlite> select [a],[b],[c] from test;
> > a, b, c
> > 1, 2, drie
> > 4, 5, zes
> > sqlite> select "a","b","c" from test;
> > a, b, c
> > 1, 2, drie
> > 4, 5, zes
> >
> > Of course, you shoul not use single quotes ;)
> > sqlite> select 'a','b','c' from test;
> > 'a', 'b', 'c'
> > a, b, c
> > a, b, c
> > sqlite>|
> > _______________________________________________
> > sqlite-users mailing list
> > [hidden email]
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

R Smith
In reply to this post by Bart Smissaert

On 2018/01/03 12:15 PM, Bart Smissaert wrote:
> Is there a way with pragma table_info or otherwise (other than parsing the
> table create statement from SQLite_master) to get the column names
> including the column delimiters, eg double quotes or square brackets? So I
> would get eg: [column1] [column2] etc. if indeed the column names were
> delimited like that.

Don't think so, those are meta, it's like asking if there is a way to
tell from the compiled program what the comments in the code was that
the programmer inserted when coding...  The compiler very correctly
discards it and no trace of it exists in the compiled program.

I have made a few parsers for the SQLite schemata and also you can
probably copy paste some code for it directly from the SQLite source,
but may I ask why you would need that information? (Perhaps the problem
can be solved another way)



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

R Smith-2
In reply to this post by Bart Smissaert
On 2018/01/03 12:15 PM, Bart Smissaert wrote:
> Is there a way with pragma table_info or otherwise (other than parsing the
> table create statement from SQLite_master) to get the column names
> including the column delimiters, eg double quotes or square brackets? So I
> would get eg: [column1] [column2] etc. if indeed the column names were
> delimited like that.

Don't think so, those are meta, it's like asking if there is a way to
tell from the compiled program what the comments in the code was that
the programmer inserted when coding...  The compiler very correctly
discards it and no trace of it exists in the compiled program.

I have made a few parsers for the SQLite schemata and also you can
probably copy paste some code for it directly from the SQLite source,
but may I ask why you would need that information? (Perhaps the problem
can be solved another way)


(Accidentally sent this on another mail first, so if it comes through
twice, my apologies...)

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: pragma table_info return column delimiters?

Bart Smissaert
In reply to this post by Richard Hipp-3
OK, thanks. I am getting the information now from the create table
statements
and sofar that seems to work OK. Just wanted to make sure there wasn't a
better
way to handle this.

RBS

On Wed, Jan 3, 2018 at 11:08 AM, Richard Hipp <[hidden email]> wrote:

> On 1/3/18, Bart Smissaert <[hidden email]> wrote:
> > Is there a way with pragma table_info or otherwise (other than parsing
> the
> > table create statement from SQLite_master) to get the column names
> > including the column delimiters, eg double quotes or square brackets? So
> I
> > would get eg: [column1] [column2] etc. if indeed the column names were
> > delimited like that.
>
> No.  SQLite does not retain that information in its internal symbol
> tables.  You'll have to parse out the original CREATE TABLE statements
> to figure that out.
> --
> D. Richard Hipp
> [hidden email]
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users