[BangPypers] DBF error

Aravind Muthu aravind.geek at gmail.com
Thu Nov 19 12:41:48 CET 2009


from dbfpy import dbf


def OpenFile(tblName):
      '''fpath = os.path.join(local.DB_DIR,tblName)'''
      '''f=open(tblName,"ab+")'''
      db=dbf.Dbf(tblName,True)
      db.addField(
          ("NAME","C",15),
          ("SName","C",15),
      )
      for(n ,s ) in (
         ("john","miller"),
      ):
         rec=db.newRecord()
         rec["NAME"]=n
         rec["SNAME"]=s
         rec.store()
      db.close()

OpenFile("test.dbf")



sure it will work..check it out

On 11/19/09, Ranganath s <ranganaths at gmail.com> wrote:
> well i did check for it. But if you look in to the dbf.py in the dbf module
> may be you can understand. Here is my imports on interpreter,
>
> @anand,These are silly errors. If you need to post to a forum for resolving
> them,
>  there is something wrong with your way of coding.
>>> Yep, i do know there is some thing wrong with this code. just requesting
> geeks out there in python to just help out  thats it..
>
> ==============================
> ==================
>>>> from dbfpy import dbf
>>>> from dbfpy import Dbf
>
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in <module>
>     from dbfpy import Dbf
> ImportError: cannot import name Dbf
>>>> db = dbf("abcd",True)
>
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in <module>
>     db = dbf("abcd",True)
> ============================================
>
> -Ranganath.S
>
> On Thu, Nov 19, 2009 at 4:36 PM, Anand Balachandran Pillai <
> abpillai at gmail.com> wrote:
>
>> On Thu, Nov 19, 2009 at 4:24 PM, Ranganath s <ranganaths at gmail.com> wrote:
>>
>> > HI all,
>> >
>> >        i have installed the DBF module and  just wrote a small program
>> > as
>> > follows :-
>> > from dbfpy import dbf
>> >
>> >
>> > def OpenFile(tblName):
>> >       '''fpath = os.path.join(local.DB_DIR,tblName)'''
>> >       '''f=open(tblName,"ab+")'''
>> >       db=Dbf(tblName,True)
>> >       db.addField(
>> >           ("NAME","C",15),
>> >           ("SName","C",15),
>> >       )
>> >       for(n ,s ) in (
>> >          ("john","miller"),
>> >       ):
>> >          rec=db.newRecord()
>> >          rec["NAME"]=n
>> >          rec["SNAME"]=s
>> >          rec.store()
>> >       db.close()
>> >
>> > OpenFile("test.dbf")
>> >
>> > =============================
>> > This programs gives error as follows
>> > =============================
>> > cursor at cursor:~/SchoolManagementSystem$ python test.py
>> > Traceback (most recent call last):
>> >  File "test.py", line 23, in <module>
>> >    OpenFile("test.dbf")
>> >  File "test.py", line 9, in OpenFile
>> >    db=Dbf(tblName,True)
>> > NameError: global name 'Dbf' is not defined
>> > =================================================================
>> >
>>
>>  Dbf != dbf
>>
>>  You are importing module as "dbf" so how do you expect name "Dbf"
>>  to be there ?
>>
>>  These are silly errors. If you need to post to a forum for resolving
>> them,
>>  there is something wrong with your way of coding.
>>
>>
>> >
>> >  Can some one point out like where am i going wrong.
>> >
>> > Thank you
>> > Ranganath.S
>> >
>> >
>> >
>> >
>> > --
>> > I blog at http://ranganaths.wordpress.com
>> > _______________________________________________
>> > BangPypers mailing list
>> > BangPypers at python.org
>> > http://mail.python.org/mailman/listinfo/bangpypers
>> >
>>
>>
>>
>> --
>> --Anand
>> _______________________________________________
>> BangPypers mailing list
>> BangPypers at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> I blog at http://ranganaths.wordpress.com
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list