Python论坛  - 讨论区

标题:[python-chinese] pysqlite无法插入数据

2007年12月28日 星期五 09:18

吕新志 lvxinzhi在gmail.com
星期五 十二月 28 09:18:11 HKT 2007

# -*- coding: utf-8 -*-
#from pysqlite2 import dbapi2 as sqlite
import sqlite
import wx

con=sqlite.connect("xn.db")
cur = con.cursor()
cur.execute("SELECT * FROM tt")

newPeople=(
    ('Lebed',53),
    ('Zhirinovsky',57),
)
for person in newPeople:
    cur.execute("INSERT INTO tt (name_last,age) VALUES (?,?)",person)
#修改之后必须明确的提交
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 16, in ?
    cur.execute("INSERT INTO tt (name_last,age) VALUES (?,?)",person)
  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月28日 星期五 10:21

BloodMage zhouyisu在gmail.com
星期五 十二月 28 10:21:25 HKT 2007

°Ñ"INSERT INTO tt (name_last,age) VALUES (?,?)"¸Ä³É"INSERT INTO tt
(name_last,age) VALUES (%s,%s)"ÊÔÊÔ£¿

2007/12/28, ÂÀÐÂÖ¾ <lvxinzhi在gmail.com>:
>
> # -*- coding: utf-8 -*-
> #from pysqlite2 import dbapi2 as sqlite
> import sqlite
> import wx
>
> con=sqlite.connect("xn.db")
> cur = con.cursor()
> cur.execute("SELECT * FROM tt")
>
> newPeople=(
>     ('Lebed',53),
>     ('Zhirinovsky',57),
> )
> for person in newPeople:
>     cur.execute("INSERT INTO tt (name_last,age) VALUES (?,?)",person)
> #ÐÞ¸ÄÖ®ºó±ØÐëÃ÷È·µÄÌá½»
> 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 16, in ?
>     cur.execute("INSERT INTO tt (name_last,age) VALUES (?,?)",person)
>   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/7ddce666/attachment.htm 

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

2007年12月28日 星期五 10:38

python python python在tairan.net
星期五 十二月 28 10:38:31 HKT 2007

hi,
 
    In the time module, use the time.sleep(seconds) function À´ÊµÏÖ¶¨Ê±Æ÷µÄ¹¦ÄÜ
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071228/e1a77072/attachment.htm 

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

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

lai yonghao lanphaday在gmail.com
星期五 十二月 28 11:42:49 HKT 2007

Äã¿ÉÒÔÊÔÊÔ sched Ä£¿é

>>> import sched, time
>>> s=sched.scheduler(time.time, time.sleep)
>>> def print_time(): print "From print_time", time.time()
...
>>> def print_some_times():
...     print time.time()
...     s.enter(5, 1, print_time, ())
...     s.enter(10, 1, print_time, ())
...     s.run()
...     print time.time()
...
>>> print_some_times()
930343690.257
From print_time 930343695.274
From print_time 930343700.273
930343700.276



ÔÚ07-12-28£¬python python <python在tairan.net> дµÀ£º
>
> hi,
>
>     In the time module, use the time.sleep(seconds) function À´ÊµÏÖ¶¨Ê±Æ÷µÄ¹¦ÄÜ
>
> ------------------------------
> Express yourself instantly with MSN Messenger! MSN Messenger<http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/>
>
> _______________________________________________
> 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/50c16f9f/attachment.htm 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号