Python论坛  - 讨论区

标题:[python-chinese] 有没有什么好用的文件型数据库

2005年02月06日 星期日 13:47

duotaiya duotaiya duotaiya at yahoo.com.cn
Sun Feb 6 13:47:13 HKT 2005

最近想写一个日记程序。
考虑用数据库文件存储日记
本来想用gdbm的,但是我不知道怎么插入key,而且

问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
谢谢

_________________________________________________________
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
http://music.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图
http://image.yisou.com
1G就是1000兆,雅虎电邮自助扩容!
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/


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

2005年02月06日 星期日 13:52

Zoom Quiet zoom.quiet at gmail.com
Sun Feb 6 13:52:56 HKT 2005

XML
SQlite 
DB4
等等
都可以的


On Sun, 6 Feb 2005 13:47:13 +0800 (CST), duotaiya duotaiya
<duotaiya at yahoo.com.cn> wrote:
> 最近想写一个日记程序。
> 考虑用数据库文件存储日记
> 本来想用gdbm的,但是我不知道怎么插入key,而且
> 
> 问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
> 谢谢
> 
> _________________________________________________________
> Do You Yahoo!?
> 150万曲MP3疯狂搜,带您闯入音乐殿堂
> http://music.yisou.com/
> 美女明星应有尽有,搜遍美图、艳图和酷图
> http://image.yisou.com
> 1G就是1000兆,雅虎电邮自助扩容!
> http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 


-- 
[Time is unimportant, only life important!]


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

2005年02月06日 星期日 13:54

fla liu fla.liu at gmail.com
Sun Feb 6 13:54:04 HKT 2005

这个一定是 sqlite了
官方站点 www.sqlite.org

On Sun, 6 Feb 2005 13:47:13 +0800 (CST), duotaiya duotaiya
<duotaiya at yahoo.com.cn> wrote:
> 最近想写一个日记程序。
> 考虑用数据库文件存储日记
> 本来想用gdbm的,但是我不知道怎么插入key,而且
> 
> 问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
> 谢谢
> 
> _________________________________________________________
> Do You Yahoo!?
> 150万曲MP3疯狂搜,带您闯入音乐殿堂
> http://music.yisou.com/
> 美女明星应有尽有,搜遍美图、艳图和酷图
> http://image.yisou.com
> 1G就是1000兆,雅虎电邮自助扩容!
> http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>


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

2005年02月06日 星期日 15:06

Frank gavin at sz.net.cn
Sun Feb 6 15:06:09 HKT 2005

如何在python中使用sqlite?

我知道有一个专门为python开发的sqlite内嵌数据库pysqlite(http://pysqlite.org)




----- Original Message ----- 
From: "fla liu" <fla.liu at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Sunday, February 06, 2005 1:54 PM
Subject: Re: [python-chinese] 有没有什么好用的文件型数据 库


这个一定是 sqlite了
官方站点 www.sqlite.org

On Sun, 6 Feb 2005 13:47:13 +0800 (CST), duotaiya duotaiya
<duotaiya at yahoo.com.cn> wrote:
> 最近想写一个日记程序。
> 考虑用数据库文件存储日记
> 本来想用gdbm的,但是我不知道怎么插入key,而且
> 
> 问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
> 谢谢
> 
> _________________________________________________________
> Do You Yahoo!?
> 150万曲MP3疯狂搜,带您闯入音乐殿堂
> http://music.yisou.com/
> 美女明星应有尽有,搜遍美图、艳图和酷图
> http://image.yisou.com
> 1G就是1000兆,雅虎电邮自助扩容!
> http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese

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

2005年02月06日 星期日 15:10

Frank gavin at sz.net.cn
Sun Feb 6 15:10:29 HKT 2005

不好意思,找到了:)

http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers




----- Original Message ----- 
From: "Frank" <gavin at sz.net.cn>
To: "fla liu" <fla.liu at gmail.com>; <python-chinese at lists.python.cn>
Sent: Sunday, February 06, 2005 3:06 PM
Subject: Re: [python-chinese] 有没有什么好用的文件型数据 库


如何在python中使用sqlite?

我知道有一个专门为python开发的sqlite内嵌数据库pysqlite(http://pysqlite.org)




----- Original Message ----- 
From: "fla liu" <fla.liu at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Sunday, February 06, 2005 1:54 PM
Subject: Re: [python-chinese] 有没有什么好用的文件型数据 库


这个一定是 sqlite了
官方站点 www.sqlite.org

On Sun, 6 Feb 2005 13:47:13 +0800 (CST), duotaiya duotaiya
<duotaiya at yahoo.com.cn> wrote:
> 最近想写一个日记程序。
> 考虑用数据库文件存储日记
> 本来想用gdbm的,但是我不知道怎么插入key,而且
> 
> 问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
> 谢谢
> 
> _________________________________________________________
> Do You Yahoo!?
> 150万曲MP3疯狂搜,带您闯入音乐殿堂
> http://music.yisou.com/
> 美女明星应有尽有,搜遍美图、艳图和酷图
> http://image.yisou.com
> 1G就是1000兆,雅虎电邮自助扩容!
> http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese



--------------------------------------------------------------------------------


_______________________________________________
python-chinese list
python-chinese at lists.python.cn
http://python.cn/mailman/listinfo/python-chinese

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

2005年02月06日 星期日 18:20

duotaiya duotaiya duotaiya at yahoo.com.cn
Sun Feb 6 18:20:00 HKT 2005

还要编译
算了,刚才知道了gdbm的用法,准备用gdbm或者bsddb了
不过还是要谢谢了

 --- Frank <gavin at sz.net.cn> 的正文:
> 如何在python中使用sqlite?
> 
>
我知道有一个专门为python开发的sqlite内嵌数据库pysqlite(http://pysqlite.org)
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "fla liu" <fla.liu at gmail.com>
> To: <python-chinese at lists.python.cn>
> Sent: Sunday, February 06, 2005 1:54 PM
> Subject: Re: [python-chinese]
> 有没有什么好用的文件型数据 库
> 
> 
> 这个一定是 sqlite了
> 官方站点 www.sqlite.org
> 
> On Sun, 6 Feb 2005 13:47:13 +0800 (CST), duotaiya
> duotaiya
> <duotaiya at yahoo.com.cn> wrote:
> > 最近想写一个日记程序。
> > 考虑用数据库文件存储日记
> > 本来想用gdbm的,但是我不知道怎么插入key,而且
> > 
> >
>
问一下有没有什么好用的文件型数据库,随便拷贝,到处都可以使用的?
> > 谢谢
> > 
> >
>
_________________________________________________________
> > Do You Yahoo!?
> > 150万曲MP3疯狂搜,带您闯入音乐殿堂
> > http://music.yisou.com/
> > 美女明星应有尽有,搜遍美图、艳图和酷图
> > http://image.yisou.com
> > 1G就是1000兆,雅虎电邮自助扩容!
> >
>
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
> > _______________________________________________
> > python-chinese list
> > python-chinese at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
> >
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> > _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>  

_________________________________________________________
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
http://music.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图
http://image.yisou.com
1G就是1000兆,雅虎电邮自助扩容!
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/


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

2005年02月06日 星期日 20:37

唐国巍 tgw_cl at 163.net
Sun Feb 6 20:37:05 HKT 2005

python-chinese,您好!

	经常在文件开头看到这样的引用import sys,可是搜遍了目录也找不到这个sys.py在哪,这是怎么回事

        致
礼!
 				

        唐国巍
        tgw_cl at 163.net
          2005-02-06

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

2005年02月10日 星期四 19:48

SeSe sese at 263.net
Thu Feb 10 19:48:35 HKT 2005

大年初一下雨,灭的出去,就用Python写了这么个东西,
其实我需要的是C++的ini parser库,libini看起来不
爽,所以自己用Python写了一个,然后用C++来调用,
因此里面有些函数很奇怪,比如数据类型转换。。那是
给C++ code用的,Python自己不用。C++代码稍后贴

Licenced under BSD Licence,嗯嗯,新年rp ++

大家新年好!



# Copyright (c) 2005 Huacheng Ke <sese at 263.net>
# All rights reserved.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import string
import re
import types

INI_BOOL = 1
INI_INTEGER = 2
INI_DOUBLE = 3
INI_STRING = 4

INI_EXIST = 0
INI_NO_SECTION = 1
INI_NO_KEY = 2

class INI_File:
def __init__(self):
self.__buffer = {}

def test_exist(self, section, key = ''):
if not self.__buffer.has_key(section):
return INI_NO_SECTION
elif key == '':
return INI_EXIST
elif self.__buffer[section].has_key(key):
return INI_EXIST
else:
return INI_NO_KEY

def get_type(self, str):
str = str.strip()
assert(self.count_element(str) == 1)
try:
string.atoi(str)
except ValueError:
try:
string.atof(str)
except ValueError:
return INI_STRING
return INI_DOUBLE
int_value = string.atoi(str)
if int_value == 1 or int_value == 0:
return INI_BOOL
else:
return INI_INTEGER

def count_element(self, str):
str = str.strip()
segments = string.split(str, ',')
return len(segments)

def get_sub_string(self, str, index):
str = str.strip()
assert(self.count_element(str) > 1)
segments = string.split(str, ',')
assert(index < len(segments))
return segments[index]

def to_int(self, str):
assert(self.get_type(str) <= INI_INTEGER)
return string.atoi(str)

def to_bool(self, str):
assert(self.get_type(str) == INI_BOOL)
return string.atoi(str)

def to_double(self, str):
assert(self.get_type(str) <= INI_DOUBLE)
return string.atof(str)

def retrieve_string(self, section, key):
assert(self.test_exist(section, key) == INI_EXIST)
return self.__buffer[section][key]

def start_section(self, section):
# section == '' indicates the global section
self.__buffer[section] = {}

def insert_item(self, section, key, value):
self.__buffer[section][key] = value
def clear(self):
self.__buffer = {}
def print_buffer(self):
print self.__buffer

class INI_Reader:
def __init__(self):
self.verbose = False
def toggle_verbose(self, val):
self.verbose = val
def read(self, filename):
try:
f = open(filename)
lines = f.readlines()
lines = [line.rstrip('\n') for line in lines]
lines = [line.strip() for line in lines]
f.close()
except IOError:
lines = []
return None
print "PyINI: Parsing INI file : " + filename
result = INI_File()
section_pattern = re.compile('\[\w*\]')
section = ''
result.start_section('')
for line in lines:
if line == '':
continue
match_result = section_pattern.match(line)
if match_result:
# this line is a section tag
section = match_result.group(0).strip('\[\]')
result.start_section(section)
else:
segments = string.split(line, ';')
line = segments[0].strip()
if line != '':
segments = string.split(line, "=")
segments = [ segment.strip() for segment in segments]
if len(segments) == 2:
key = segments[0]
value = segments[1]
if self.verbose:
print " [" + section + "] : <" + key + '> = <' + value + '>'
result.insert_item(section, key, value)
else:
print "PyINI: Invalid line - " + segments[0]
print "Powered by PyINI, http://pyini.sourceforge.net/"
return result

if __name__ == "__main__":
reader = INI_Reader()
result = reader.read("1.ini")
result.print_buffer()
print result.test_exist('MAIN','e')









>
>
>  
>



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

2005年02月12日 星期六 15:04

limodou limodou at gmail.com
Sat Feb 12 15:04:25 HKT 2005

python已经提供了这样的标准库,ConfigParser可以参考。

SeSe wrote:
> 大年初一下雨,灭的出去,就用Python写了这么个东西,
> 其实我需要的是C++的ini parser库,libini看起来不
> 爽,所以自己用Python写了一个,然后用C++来调用,
> 因此里面有些函数很奇怪,比如数据类型转换。。那是
> 给C++ code用的,Python自己不用。C++代码稍后贴
> 
> Licenced under BSD Licence,嗯嗯,新年rp ++
> 
> 大家新年好!
> 
> 
> 
> # Copyright (c) 2005 Huacheng Ke <sese at 263.net>
> # All rights reserved.
> 
> # Redistribution and use in source and binary forms, with or without
> # modification, are permitted provided that the following conditions
> # are met:
> # 1. Redistributions of source code must retain the above copyright
> # notice, this list of conditions and the following disclaimer.
> # 2. Redistributions in binary form must reproduce the above copyright
> # notice, this list of conditions and the following disclaimer in the
> # documentation and/or other materials provided with the distribution.
> # 3. The name of the author may not be used to endorse or promote products
> # derived from this software without specific prior written permission.
> #
> # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> 
> import string
> import re
> import types
> 
> INI_BOOL = 1
> INI_INTEGER = 2
> INI_DOUBLE = 3
> INI_STRING = 4
> 
> INI_EXIST = 0
> INI_NO_SECTION = 1
> INI_NO_KEY = 2
> 
> class INI_File:
> def __init__(self):
> self.__buffer = {}
> 
> def test_exist(self, section, key = ''):
> if not self.__buffer.has_key(section):
> return INI_NO_SECTION
> elif key == '':
> return INI_EXIST
> elif self.__buffer[section].has_key(key):
> return INI_EXIST
> else:
> return INI_NO_KEY
> 
> def get_type(self, str):
> str = str.strip()
> assert(self.count_element(str) == 1)
> try:
> string.atoi(str)
> except ValueError:
> try:
> string.atof(str)
> except ValueError:
> return INI_STRING
> return INI_DOUBLE
> int_value = string.atoi(str)
> if int_value == 1 or int_value == 0:
> return INI_BOOL
> else:
> return INI_INTEGER
> 
> def count_element(self, str):
> str = str.strip()
> segments = string.split(str, ',')
> return len(segments)
> 
> def get_sub_string(self, str, index):
> str = str.strip()
> assert(self.count_element(str) > 1)
> segments = string.split(str, ',')
> assert(index < len(segments))
> return segments[index]
> 
> def to_int(self, str):
> assert(self.get_type(str) <= INI_INTEGER)
> return string.atoi(str)
> 
> def to_bool(self, str):
> assert(self.get_type(str) == INI_BOOL)
> return string.atoi(str)
> 
> def to_double(self, str):
> assert(self.get_type(str) <= INI_DOUBLE)
> return string.atof(str)
> 
> def retrieve_string(self, section, key):
> assert(self.test_exist(section, key) == INI_EXIST)
> return self.__buffer[section][key]
> 
> def start_section(self, section):
> # section == '' indicates the global section
> self.__buffer[section] = {}
> 
> def insert_item(self, section, key, value):
> self.__buffer[section][key] = value
> def clear(self):
> self.__buffer = {}
> def print_buffer(self):
> print self.__buffer
> 
> class INI_Reader:
> def __init__(self):
> self.verbose = False
> def toggle_verbose(self, val):
> self.verbose = val
> def read(self, filename):
> try:
> f = open(filename)
> lines = f.readlines()
> lines = [line.rstrip('\n') for line in lines]
> lines = [line.strip() for line in lines]
> f.close()
> except IOError:
> lines = []
> return None
> print "PyINI: Parsing INI file : " + filename
> result = INI_File()
> section_pattern = re.compile('\[\w*\]')
> section = ''
> result.start_section('')
> for line in lines:
> if line == '':
> continue
> match_result = section_pattern.match(line)
> if match_result:
> # this line is a section tag
> section = match_result.group(0).strip('\[\]')
> result.start_section(section)
> else:
> segments = string.split(line, ';')
> line = segments[0].strip()
> if line != '':
> segments = string.split(line, "=")
> segments = [ segment.strip() for segment in segments]
> if len(segments) == 2:
> key = segments[0]
> value = segments[1]
> if self.verbose:
> print " [" + section + "] : <" + key + '> = <' + value + '>'
> result.insert_item(section, key, value)
> else:
> print "PyINI: Invalid line - " + segments[0]
> print "Powered by PyINI, http://pyini.sourceforge.net/"
> return result
> 
> if __name__ == "__main__":
> reader = INI_Reader()
> result = reader.read("1.ini")
> result.print_buffer()
> print result.test_exist('MAIN','e')
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>>
>> 
>>
> 
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 

-- 
I love python!
My Blog: http://www.donews.net/limodou


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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号