Python论坛  - 讨论区

标题:[python-chinese] pysqlite2无法往数据库接入数据,请指点

2007年12月27日 星期四 11:02

吕新志 lvxinzhi在gmail.com
星期四 十二月 27 11:02:45 HKT 2007

表结构
CREATE TABLE people
(
    name_last   varchar(20),
    age         integer
);


以下是SQL语句
# -*- coding: utf-8 -*-
#from pysqlite2 import dbapi2 as sqlite
import sqlite

con=sqlite.connect("xn.db")

cur=con.cursor()

#cur.execute("SELECT * FROM item_type where code >5")

newPeople=(
    ('Lebed',53),
    ('Zhirinovsky',57),
)
#for person in newPeople:
#    cur.execute("INSERT INTO people (name_last,age) VALUES (?,?)",person)
cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
con.commit()
#data = cur.fetchall()
#for i in data:
#    print i
#
#cur.close()


Traceback (most recent call last):
  File "D:\workspace\wx\src\consqlite.py", line 17, in ?
    cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
  File "C:\Python24\Lib\site-packages\sqlite\main.py", line 255, in execute
    self.rs = self.con.db.execute(SQL % parms)
TypeError: not all arguments converted during string formatting

-- 
          ,        ," 1+
	              /(        )`" 1+
	              \ \___   / |" 1+
	              /- _  `-/  '" 1+
	             (/\/ \ \   /\" 1+
	             / /   | `    \" 1+
	             O O   ) /    |" 1+
	             `-^--'`<     '" 1+
	            (_.)  _  )   /" 1+
	             `.___/`    /" 1+
	               `-----' /" 1+
	  <----.     __ / __   \" 1+
	  <----|====O)))==) \) /====" 1+
	  <----'    `--' `.__,' \" 1+
	               |        |" 1+
	                \       /       /\" 1+
	           ______( (_  / \______/" 1+
	         ,'  ,-----'   |" 1+
	         `--{__________)"

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月27日 星期四 11:22

nmweizi nmweizi在163.com
星期四 十二月 27 11:22:33 HKT 2007

python-chinese£¬ÄãºÃ
ÕâÑùд¾Í¿ÉÒÔÁË¡£
cur.execute("INSERT INTO people (name_last) VALUES (?)",(str("aa"),))

nmweizi£¬nmweizi在163.com
2007-12-27 
----- Original Message ----- 
From: ÂÀÐÂÖ¾ 
To: python-chinese 
Sent: 2007-12-27, 11:02:45
Subject: [python-chinese] pysqlite2ÎÞ·¨ÍùÊý¾Ý¿â½ÓÈëÊý¾Ý£¬ÇëÖ¸µã


±í½á¹¹
CREATE TABLE people
(
    name_last varchar(20),
    age integer
);


ÒÔÏÂÊǣӣѣÌÓï¾ä
# -*- coding: utf-8 -*-
#from pysqlite2 import dbapi2 as sqlite
import sqlite

con=sqlite.connect("xn.db")

cur=con.cursor()

#cur.execute("SELECT * FROM item_type where code >5")

newPeople=(
    ('Lebed',53),
    ('Zhirinovsky',57),
)
#for person in newPeople:
# cur.execute("INSERT INTO people (name_last,age) VALUES (?,?)",person)
cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
con.commit()
#data = cur.fetchall()
#for i in data:
# print i
#
#cur.close()


Traceback (most recent call last):
  File "D:\workspace\wx\src\consqlite.py", line 17, in ?
    cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
  File "C:\Python24\Lib\site-packages\sqlite\main.py", line 255, in execute
    self.rs = self.con.db.execute(SQL % parms)
TypeError: not all arguments converted during string formatting

-- 
          , ," 1+
                /( )`" 1+
                \ \___ / |" 1+
                /- _ `-/ '" 1+
               (/\/ \ \ /\" 1+
               / / | ` \" 1+
               O O ) / |" 1+
               `-^--'`< '" 1+
              (_.) _ ) /" 1+
               `.___/` /" 1+
                 `-----' /" 1+
    <----. __ / __ \" 1+
    <----|====O)))==) \) /====" 1+
    <----' `--' `.__,' \" 1+
                 | |" 1+
                  \ / /\" 1+
             ______( (_ / \______/" 1+
           ,' ,-----' |" 1+
           `--{__________)"
_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071227/45667ee6/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年12月28日 星期五 11:13

nmweizi nmweizi在163.com
星期五 十二月 28 11:13:28 HKT 2007

python-chinese£¬ÄãºÃ
ÕâÑùд¾Í¿ÉÒÔÁË¡£
cur.execute("INSERT INTO people (name_last) VALUES (?)",(str("aa"),))

nmweizi在gmail.com£¬nmweizi在gmail.com
2007-12-27 
----- Original Message ----- 
From: ÂÀÐÂÖ¾ 
To: python-chinese 
Sent: 2007-12-27, 11:02:45
Subject: [python-chinese] pysqlite2ÎÞ·¨ÍùÊý¾Ý¿â½ÓÈëÊý¾Ý£¬ÇëÖ¸µã


±í½á¹¹
CREATE TABLE people
(
    name_last varchar(20),
    age integer
);


ÒÔÏÂÊǣӣѣÌÓï¾ä
# -*- coding: utf-8 -*-
#from pysqlite2 import dbapi2 as sqlite
import sqlite

con=sqlite.connect("xn.db")

cur=con.cursor()

#cur.execute("SELECT * FROM item_type where code >5")

newPeople=(
    ('Lebed',53),
    ('Zhirinovsky',57),
)
#for person in newPeople:
# cur.execute("INSERT INTO people (name_last,age) VALUES (?,?)",person)
cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
con.commit()
#data = cur.fetchall()
#for i in data:
# print i
#
#cur.close()


Traceback (most recent call last):
  File "D:\workspace\wx\src\consqlite.py", line 17, in ?
    cur.execute("INSERT INTO people (name_last) VALUES (?)",str("aa"))
  File "C:\Python24\Lib\site-packages\sqlite\main.py", line 255, in execute
    self.rs = self.con.db.execute(SQL % parms)
TypeError: not all arguments converted during string formatting

-- 
          , ," 1+
                /( )`" 1+
                \ \___ / |" 1+
                /- _ `-/ '" 1+
               (/\/ \ \ /\" 1+
               / / | ` \" 1+
               O O ) / |" 1+
               `-^--'`< '" 1+
              (_.) _ ) /" 1+
               `.___/` /" 1+
                 `-----' /" 1+
    <----. __ / __ \" 1+
    <----|====O)))==) \) /====" 1+
    <----' `--' `.__,' \" 1+
                 | |" 1+
                  \ / /\" 1+
             ______( (_ / \______/" 1+
           ,' ,-----' |" 1+
           `--{__________)"
_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071228/74ee6eda/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号