python 3.x - Sqlite3 hidden formatting of columns -


i have been researching issue, results ever name sqlite's .width function, or refer pragma , similar find out hidden values. problem this: have database query in kinds of ways under ".mode column", , ".headers on". rule width of columns seems either 10, or length of header of column, depending on larger.(..this true when headers not displayed) now, columns in -as of now- 2 tables in database have longer column widths, instead match length of data (..instead of header).

for example have "date" column 4 signs, column width should default 10, instead expanded 15 fit long date codes "636363515212222". thought, maybe long integers expand too, in example got "uuid" mere text-strings data, going 34 characters or so.

note, in every other example there text or large integers (which tested), output of data truncated fit column width, like

somelongnames .............. "herbert wate

i tried copy 1 of long uuid-entries table, see if width adapt automatically form of input reason. didn't, , uuid got truncated. conclusion left here tables harbor custom formatting of columns, unable find those. tried:

  • "schema(table)" give create table statement, there no signs of additional formatting.

  • "pragma table_info(table_name)" list types, no varchar (anywhere!) or can seen explain effect.

  • "select * sqlite_master" mixture of both others, contains again nothing more.

  • ".width" doesn't give option specify column width tables, no matter question information stored, if can't find above commands.

so question now: how come be? somehow tables must have ended this. created in other sql types?(i analyzing database learn python programmed access) however, in case, sqlite must know somehow, there must sort of formatting pointer in of this. ...but where?

i highly need btw. make python output consistent when doing remote sql-queries. no way around other not touching specific columns, cheap.

there no formatting information stored in database.

the sqlite3 command-line shell tries automatically detect column widths column names , first row's values code:

    for(i=0; i<narg; i++){       int w, n;       if( i<arraysize(p->colwidth) ){         w = colwidth[i];       }else{         w = 0;       }       if( w==0 ){         w = strlenchar(azcol[i] ? azcol[i] : "");         if( w<10 ) w = 10;         n = strlenchar(azarg && azarg[i] ? azarg[i] : p->nullvalue);         if( w<n ) w = n;       }       if( i<arraysize(p->actualwidth) ){         p->actualwidth[i] = w;       }       if( showhdr ){         utf8_width_print(p->out, w, azcol[i]);         utf8_printf(p->out, "%s", i==narg-1 ? rowsep : "  ");       }     }     if( showhdr ){       for(i=0; i<narg; i++){         int w;         if( i<arraysize(p->actualwidth) ){            w = p->actualwidth[i];            if( w<0 ) w = -w;         }else{            w = 10;         }         utf8_printf(p->out,"%-*.*s%s",w,w,                "----------------------------------------------------------"                "----------------------------------------------------------",                 i==narg-1 ? rowsep : "  ");       }     } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -