sqlite3 create table col width?

2007-08-04 Thread jim-on-linux
PY help,

Using sqlite3 v3.1.3

When I create a table collumn using;

newcollum VARCHAR(35),

I get a default of 10 spaces.

No matter what I set the size to I get 10 spqces, 
even using varchar(0) defaults to 10 spaces.

I would appreciae the help if someone could tell 
me what I'm missing, I want to varry the column 
sizes.

jim-on-linux



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 create table col width?

2007-08-04 Thread Paddy
On Aug 4, 6:51 pm, jim-on-linux [EMAIL PROTECTED] wrote:
 PY help,

 Using sqlite3 v3.1.3

 When I create a table collumn using;

 newcollum VARCHAR(35),

 I get a default of 10 spaces.

 No matter what I set the size to I get 10 spqces,
 even using varchar(0) defaults to 10 spaces.

 I would appreciae the help if someone could tell
 me what I'm missing, I want to varry the column
 sizes.

 jim-on-linux

Hi Jim,
You need to create a new thread for this new question so it gets
maximum visibility and so is more likely to be answered.

- Paddy.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 create table col width?

2007-08-04 Thread Carsten Haese
On Sat, 2007-08-04 at 13:51 -0400, jim-on-linux wrote:
 PY help,
 
 Using sqlite3 v3.1.3
 
 When I create a table collumn using;
 
 newcollum VARCHAR(35),
 
 I get a default of 10 spaces.
 
 No matter what I set the size to I get 10 spqces, 
 even using varchar(0) defaults to 10 spaces.
 
 I would appreciae the help if someone could tell 
 me what I'm missing, I want to varry the column 
 sizes.

What you're missing is that sqlite columns are type-less. Column type
and size are irrelevant:

 import sqlite3
 conn = sqlite3.connect(:memory)
 cur = conn.cursor()
 cur.execute(create table t1 (c1 varchar(35)))
sqlite3.Cursor object at 0xb7f6dbf0
 cur.executemany(insert into t1(c1) values(?),
... [ (X*i*10,) for i in range(10) ] )
 cur.execute(select * from t1)
sqlite3.Cursor object at 0xb7f6dbf0
 for row in cur: print row
... 
(u'',)
(u'XX',)
(u'',)
(u'XX',)
(u'',)
(u'XX',)
(u'',)
(u'XX',)
(u'',)
(u'XX',)

Even though the column was created to be 35 characters wide, it'll
happily accept 100-character strings.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 create table col width?

2007-08-04 Thread jim-on-linux
On Saturday 04 August 2007 14:05, Carsten Haese 
wrote:
 On Sat, 2007-08-04 at 13:51 -0400, jim-on-linux 
wrote:
  PY help,
 
  Using sqlite3 v3.1.3
 
  When I create a table collumn using;
 
  newcollum VARCHAR(35),
 
  I get a default of 10 spaces.
 
  No matter what I set the size to I get 10
  spqces, even using varchar(0) defaults to 10
  spaces.
 
  I would appreciae the help if someone could
  tell me what I'm missing, I want to varry the
  column sizes.

 What you're missing is that sqlite columns are
 type-less. Column type

 and size are irrelevant:
  import sqlite3
  conn = sqlite3.connect(:memory)
  cur = conn.cursor()
  cur.execute(create table t1 (c1
  varchar(35)))

 sqlite3.Cursor object at 0xb7f6dbf0

  cur.executemany(insert into t1(c1)
  values(?),

 ... [ (X*i*10,) for i in range(10) ] )

  cur.execute(select * from t1)

 sqlite3.Cursor object at 0xb7f6dbf0

  for row in cur: print row

 ...
 (u'',)
 (u'XX',)
 (u'',)
 (u'XX',)
 (u'',)
 (u'
XX',)
 (u'
',)
 (u'
XX',)
 (u'
',)
 (u'
XX',
)

 Even though the column was created to be 35
 characters wide, it'll happily accept
 100-character strings.

 HTH,

 --
 Carsten Haese
 http://informixdb.sourceforge.net


Right, the data is there. 
My question is framed wrong.  Your answer pointed 
out the flaw in the question.

Since I'm on linux, the database can be opened 
with Knoda.  Once opened the table collumns are 
always 10 spaces so all the data is not readable 
as presented.  Not quite a python problem.  

I can Tk a display for the data, just thought I 
could save time by letting the user open the 
table and read the data right from the table.

Thanks for the help.

jim-on-linux

 




















-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 create table col width?

2007-08-04 Thread Ben Finney
jim-on-linux [EMAIL PROTECTED] writes:

 PY help,
 
 Using sqlite3 v3.1.3

You made this message a reply to an existing discussion, so your
message is now part of that existing discussion. Please start a new
discussion thread by composing a new message.

-- 
 \ True greatness is measured by how much freedom you give to |
  `\  others, not by how much you can coerce others to do what you |
_o__) want.  --Larry Wall |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list