Python论坛  - 讨论区

标题:[python-chinese] SQLAlchemy 新手问题

2007年05月18日 星期五 15:35

Question wanliyou在gmail.com
星期五 五月 18 15:35:40 HKT 2007

开门见山:
      昨天装了sqlalchemy,setup.py install
...
Installed c:\python24\lib\site-packages\sqlalchemy-0.3.7-py2.4.egg
Processing dependencies for SQLAlchemy==0.3.7
装完了后试了试
from sqlalchemy import *

my_sql_engine = create_engine('mysql', {'db': 'test', 'user':'root',
'passwd':'toor', 'host':'127.0.0.1'}, echo=True)

结果告诉我
NameError: name 'create_engine' is not defined

然后我在lib里面grep了一下
发现这行:

sqlalchemy/ext/sqlsoup.py:    >>> from sqlalchemy import create_engine

那怎么我运行不了呢?
弱问题,请不吝赐教。

-- 
//************************
  * Never  Say Never
  ************************//
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070518/4f57fdeb/attachment.htm 

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

2007年05月18日 星期五 17:18

Hong Yuan hongyuan在homemaster.cn
星期五 五月 18 17:18:18 HKT 2007

是不是以前装过其它的版本?建议在解释器中查看一下,import sqlalchemy后看
看到底是从哪里加载的模块。
如果不是你新装的,那么到site-packages中把sqlalchemy开头的文件和目录都删
掉,然后运行

easy_install -Z SQLAlchemy

重新安装。

Z:\>python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
>>> sqlalchemy

>>> from sqlalchemy import *
>>> create_engine

>>>

Question wrote:
> 开门见山:
> 昨天装了sqlalchemy,setup.py install
> ...
> Installed c:\python24\lib\site-packages\sqlalchemy-0.3.7-py2.4.egg
> Processing dependencies for SQLAlchemy==0.3.7
> 装完了后试了试
> from sqlalchemy import *
> my_sql_engine = create_engine('mysql', {'db': 'test', 'user':'root',
> 'passwd':'toor', 'host':'127.0.0.1 <http://127.0.0.1>'}, echo=True)
> 结果告诉我
> NameError: name 'create_engine' is not defined
> 然后我在lib里面grep了一下
> 发现这行:
> sqlalchemy/ext/sqlsoup.py: >>> from sqlalchemy import create_engine
> 那怎么我运行不了呢?
> 弱问题,请不吝赐教。
>
> -- 
> //************************
> * Never Say Never
> ************************//
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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


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

2007年05月18日 星期五 17:31

Question wanliyou在gmail.com
星期五 五月 18 17:31:08 HKT 2007

site-packages不是只有一个SQLAlchemy-0.3.7-py2.4.egg么?
easy_install SQLAlchemy
说我已经装好了。。。
以前也没装过,新试用一下而已


On 5/18/07, Hong Yuan <hongyuan at homemaster.cn> wrote:
>
> 是不是以前装过其它的版本?建议在解释器中查看一下,import sqlalchemy后看
> 看到底是从哪里加载的模块。
> 如果不是你新装的,那么到site-packages中把sqlalchemy开头的文件和目录都删
> 掉,然后运行
>
> easy_install -Z SQLAlchemy
>
> 重新安装。
>
> Z:\>python
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sqlalchemy
> >>> sqlalchemy
> > 'c:\python25\lib\site-packages\sqlalchemy-
> 0.3.7-py2.5.egg\sqlalchemy\__init__.pyc'>
> >>> from sqlalchemy import *
> >>> create_engine
> 
> >>>
>
> Question wrote:
> > 开门见山:
> > 昨天装了sqlalchemy,setup.py install
> > ...
> > Installed c:\python24\lib\site-packages\sqlalchemy-0.3.7-py2.4.egg
> > Processing dependencies for SQLAlchemy==0.3.7
> > 装完了后试了试
> > from sqlalchemy import *
> > my_sql_engine = create_engine('mysql', {'db': 'test', 'user':'root',
> > 'passwd':'toor', 'host':'127.0.0.1 <http://127.0.0.1>'}, echo=True)
> > 结果告诉我
> > NameError: name 'create_engine' is not defined
> > 然后我在lib里面grep了一下
> > 发现这行:
> > sqlalchemy/ext/sqlsoup.py: >>> from sqlalchemy import create_engine
> > 那怎么我运行不了呢?
> > 弱问题,请不吝赐教。
> >
> > --
> > //************************
> > * Never Say Never
> > ************************//
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese




-- 
//************************
  * Never  Say Never
  ************************//
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070518/9a91de27/attachment.htm 

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

2007年05月18日 星期五 17:40

黄毅 yi.codeplayer在gmail.com
星期五 五月 18 17:40:04 HKT 2007

是不是你自己这个模块就叫做 sqlalchemy  = ="

On 5/18/07, Question <wanliyou at gmail.com> wrote:
>
> 开门见山:
>       昨天装了sqlalchemy,setup.py install
> ...
> Installed c:\python24\lib\site-packages\sqlalchemy-0.3.7-py2.4.egg
> Processing dependencies for SQLAlchemy==0.3.7
> 装完了后试了试
> from sqlalchemy import *
>
> my_sql_engine = create_engine('mysql', {'db': 'test', 'user':'root',
> 'passwd':'toor', 'host':'127.0.0.1'}, echo=True)
>
> 结果告诉我
> NameError: name 'create_engine' is not defined
>
> 然后我在lib里面grep了一下
> 发现这行:
>
> sqlalchemy/ext/sqlsoup.py:    >>> from sqlalchemy import create_engine
>
> 那怎么我运行不了呢?
> 弱问题,请不吝赐教。
>
> --
> //************************
>   * Never  Say Never
>   ************************//
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
http://codeplayer.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070518/0ef6addf/attachment.html 

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

2007年05月18日 星期五 17:55

Question wanliyou在gmail.com
星期五 五月 18 17:55:56 HKT 2007

ft,随手save了个名字,还真没注意,谢谢了。
狂汗。。。


On 5/18/07, 黄毅 <yi.codeplayer at gmail.com> wrote:
>
> 是不是你自己这个模块就叫做 sqlalchemy  = ="
>
>  On 5/18/07, Question <wanliyou at gmail.com> wrote:
>
> >  开门见山:
> >       昨天装了sqlalchemy,setup.py install
> > ...
> > Installed c:\python24\lib\site-packages\sqlalchemy-0.3.7-py2.4.egg
> > Processing dependencies for SQLAlchemy==0.3.7
> > 装完了后试了试
> > from sqlalchemy import *
> >
> > my_sql_engine = create_engine('mysql', {'db': 'test', 'user':'root',
> > 'passwd':'toor', 'host':' 127.0.0.1'}, echo=True)
> >
> > 结果告诉我
> > NameError: name 'create_engine' is not defined
> >
> > 然后我在lib里面grep了一下
> > 发现这行:
> >
> > sqlalchemy/ext/sqlsoup.py:    >>> from sqlalchemy import create_engine
> >
> > 那怎么我运行不了呢?
> > 弱问题,请不吝赐教。
> >
> > --
> > //************************
> >   * Never  Say Never
> >   ************************//
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> http://codeplayer.blogspot.com/
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
//************************
  * Never  Say Never
  ************************//
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070518/4d067c3f/attachment-0001.htm 

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

2007年05月18日 星期五 18:05

kevin kevin_woso在126.com
星期五 五月 18 18:05:26 HKT 2007

pythoner,您好!
    请教:
    我用recv去读socket数据,但是由于不知道确切的长度,所以准备每次读1024字节然后把这些片段连起来
    可是怎么样才知道读完了呢?好像读完了,下一次recv就阻塞了.
	

        致
礼!
 				

        kevin
        kevin_woso在126.com
          2007-05-18

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

2007年05月18日 星期五 18:13

Leo Jay python.leojay在gmail.com
星期五 五月 18 18:13:56 HKT 2007

On 5/18/07, kevin <kevin_woso在126.com> wrote:
> pythoner,您好!
>     请教:
>     我用recv去读socket数据,但是由于不知道确切的长度,所以准备每次读1024字节然后把这些片段连起来
>     可是怎么样才知道读完了呢?好像读完了,下一次recv就阻塞了.

没有什么办法可以直接知道长度。不过,你可以一开始就传一个整数,表示总长度。这样client端就知道要读取的总长度了。


-- 
Best Regards,
Leo Jay

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

2007年05月18日 星期五 19:34

zhangfan yalexfan在gmail.com
星期五 五月 18 19:34:03 HKT 2007

如果对方发送完数据后,关闭了socket,读完之后的下一次recv返回 '',
所以可以通过:
while True:
	data = s.recv(1024)
	if not data:
		break
	process(data)
判断是否读完。

否则,recv就会阻塞,因为不知道对方是否还会发送数据。不过,可以把
socket设置成非阻塞模式来避免。

------------------				 
zhangfan
2007-05-18

-------------------------------------------------------------
发件人:kevin
发送日期:2007-05-18 18:06:45
收件人:Python.cn
抄送:
主题:[python-chinese]请教recv的问题

pythoner,您好!
    请教:
    我用recv去读socket数据,但是由于不知道确切的长度,所以准备每次读1024字节然后把这些片段连起来
    可是怎么样才知道读完了呢?好像读完了,下一次recv就阻塞了.
	

        致
礼!
 				

        kevin
        kevin_woso在126.com
          2007-05-18
_______________________________________________
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

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

2007年05月22日 星期二 12:44

麦田守望者 qcxhome在gmail.com
星期二 五月 22 12:44:49 HKT 2007

On 5/18/07, zhangfan <yalexfan at gmail.com> wrote:
> 如果对方发送完数据后,关闭了socket,读完之后的下一次recv返回 '',
> 所以可以通过:
> while True:
>         data = s.recv(1024)
>         if not data:
>                 break
>         process(data)
> 判断是否读完。
>
> 否则,recv就会阻塞,因为不知道对方是否还会发送数据。不过,可以把
> socket设置成非阻塞模式来避免。
>
> ------------------
> zhangfan
> 2007-05-18
>
> -------------------------------------------------------------
> 发件人:kevin
> 发送日期:2007-05-18 18:06:45
> 收件人:Python.cn
> 抄送:
> 主题:[python-chinese]请教recv的问题
>
> pythoner,您好!
>     请教:
>     我用recv去读socket数据,但是由于不知道确切的长度,所以准备每次读1024字节然后把这些片段连起来
>     可是怎么样才知道读完了呢?好像读完了,下一次recv就阻塞了.
>
>
>> 礼!
>
>
> kevin
> kevin_woso at 126.com
> 2007-05-18
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

当接收到的字节数小于传递给recv方法的缓冲区大小的时候,也能够说明数据已经接收完毕。

-- 
GoogleTalk: qcxhome at gmail.com
MSN: qcxhome at hotmail.com
My Space: tkdchen.spaces.live.com
BOINC: boinc.berkeley.edu
中国分布式计算总站: www.equn.com

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

2007年05月22日 星期二 12:55

Qiangning Hong hongqn在gmail.com
星期二 五月 22 12:55:05 HKT 2007

On 5/22/07, 麦田守望者 <qcxhome在gmail.com> wrote:
> 当接收到的字节数小于传递给recv方法的缓冲区大小的时候,也能够说明数据已经接收完毕。

no, TCP并不保证这一点。

-- 
Qiangning Hong
http://www.douban.com/people/hongqn/

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

2007年05月22日 星期二 15:08

Leo Jay python.leojay在gmail.com
星期二 五月 22 15:08:53 HKT 2007

On 5/22/07, 麦田守望者 <qcxhome在gmail.com> wrote:
> 当接收到的字节数小于传递给recv方法的缓冲区大小的时候,也能够说明数据已经接收完毕。

不是的哦。收到的字节数小于缓冲区大小的时候,只是说明,暂时还没收到其它数据。不代表对方发送的数据都已经接收完毕了。

所以我一开始的时候说,在每次通讯的最开始的4个字节写清楚
这次通讯一共要接收多少个字节的数据。
然后一直recv,直到收完所有指定的字节数为止。

-- 
Best Regards,
Leo Jay

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

2007年05月29日 星期二 00:14

散漫酷男孩 17mxnet在gmail.com
星期二 五月 29 00:14:17 HKT 2007

这个方法好 搜索了一下也都这方法

在 07-5-22,Leo Jay<python.leojay在gmail.com> 写道:
> On 5/22/07, 麦田守望者 <qcxhome在gmail.com> wrote:
> > 当接收到的字节数小于传递给recv方法的缓冲区大小的时候,也能够说明数据已经接收完毕。
>
> 不是的哦。收到的字节数小于缓冲区大小的时候,只是说明,暂时还没收到其它数据。不代表对方发送的数据都已经接收完毕了。
>
> 所以我一开始的时候说,在每次通讯的最开始的4个字节写清楚
> 这次通讯一共要接收多少个字节的数据。
> 然后一直recv,直到收完所有指定的字节数为止。
>
> --
> Best Regards,
> Leo Jay
> _______________________________________________
> 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

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号