Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 18 Feb 2018, 23:44
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
issues with bad names in peewee and python
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [1 Post]  
Author Message
sayhello_to_the_world

Joined: 24 Dec 2012
Posts: 71

PostPosted: Wed 09 Jul 2014, 12:24    Post subject:  issues with bad names in peewee and python  

update 3 - after the installation of peewwee i runned the script again,,,

Code:



    import urllib
    import urlparse
    import re
    import peewee
    import json
   
    db = MySQLDatabase('cpan', user='root',passwd='rimbaud')
   
    class User(Model):
        name = TextField()
        cname = TextField()
        email = TextField()
        url = TextField()
   
        class Meta:
            database = db # this model uses the cpan database
   
           
    User.create_table() #ensure table is created
   
   
    url = "http://search.cpan.org/author/?W"
    html = urllib.urlopen(url).read()
    for lk, capname, name in re.findall('<a href="(/~.*?/)"><b>(.*?)</b></a><br/><small>(.*?)</small>', html):
        alk = urlparse.urljoin(url, lk)
   
        data = { 'url':alk, 'name':name, 'cname':capname }
   
        phtml = urllib.urlopen(alk).read()
        memail = re.search('<a href="mailto:(.*?)">', phtml)
        if memail:
            data['email'] = memail.group(1)
           
   
    data = json.load() #your json data file here
   
    for entry in data: #assuming your data is an array of JSON objects
        user = User.create(name=entry["name"], cname=entry["cname"],
            email=entry["email"], url=entry["url"])
        user.save()
   


i got back the following results:

Code:
       

    Traceback (most recent call last):
      File "cpan5.py", line 10, in <module>
        db = MySQLDatabase('cpan', user='root',passwd='rimbaud')
    NameError: name 'MySQLDatabase' is not defined
    linux-70ce:/home/martin/perl #


well i guess that i have some issues with the name.

note:
the database is named cpan
the user is root
the passwd is rimbaud

well what do i have done wrong?

just need some tipps.

by the way : the database is up and running....a mysql db on a opensuse 13.1
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0275s ][ Queries: 11 (0.0062s) ][ GZIP on ]