Hi. I'm still learning how to use dbExpress, after using Zeos and Delphi 5 for many years. I wrote a small program to import data from a MySQL database to another MySQL database totally different in terms of layout. It worked all right, though I'm afraid some of my clients may have tables with tens of thousands of records and it may become slow or the system resources may be depleted. I tried to use TSQLDataset instead of the trio (TSQLDataset, TDatasetProvider and TClientDataset) but with only 82 iterations and 2 inserts per iteration I get a " can't create a new thread (errno 12)...". My computer has 2GB of RAM and I'm using Delphi 2007 Professional with MySQL 5.0.45. What am I doing wrong? Is it worth to bypass TClientdataset?

Thanks in advance.

Eduardo

Hi,

I'm using python to do social networking analysis. The code I'm using is given below. But when I'm using following code (after the code given below):
>>>import Facebook
>>> s=facebook.fbsession( )
Press enter after logging in:

I'm getting following error:

Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
s=Facebook.fbsession( )
File "C:/Python26/Lib\Facebook.py", line 19, in __init__
self.token=self.createtoken( )
AttributeError: fbsession instance has no attribute 'createtoken'

Can anybody help me tell why this is happening.

Regards,
Sagar

import urllib,hashlib,webbrowser,time
from xml.dom.minidom import parseString
apikey="89d21fcb455fe12709d212ccd50825d0"
secret="2e2e2a69ebf62dbee3798f7e35e42b60"
FacebookSecureURL = "https://api.facebook.com/restserver.php"
def getsinglevalue(node,tag):
  nl=node.getElementsByTagName(tag)
  if len(nl)>0:
    tagNode=nl[0]
    if tagNode.hasChildNodes( ):
      return tagNode.firstChild.nodeValue
  return ''
def callid( ):
  return str(int(time.time( )*10))
class fbsession:
  def __init__(self):
     self.session_secret=None
     self.session_key=None
     self.token=self.createtoken( )
     webbrowser.open(self.getlogin( ))
     print "Press enter after logging in:",
     raw_input( )
     self.getsession( )
def sendrequest(self, args):
  args['api_key'] = apikey
  args['sig'] = self.makehash(args)
  post_data = urllib.urlencode(args)
  url = FacebookURL + "?" + post_data
  data=urllib.urlopen(url).read( )
  return parseString(data)
def makehash(self,args):
  hasher = md5.new(''.join([x + '=' + args[x] for x in sorted(args.keys( ))]))
  if self.session_secret: hasher.update(self.session_secret)
  else: hasher.update(secret)
  return hasher.hexdigest( )
def createtoken(self):
  res = self.sendrequest({'method':"facebook.auth.createToken"})
  self.token = getsinglevalue(res,'token')
def getlogin(self):
  return "http://api.facebook.com/login.php?api_key="+apikey+\
        "&auth_token=" + self.token
def getsession(self):
  doc=self.sendrequest({'method':'facebook.auth.getSession',
                            'auth_token':self.token})
  self.session_key=getsinglevalue(doc,'session_key')
  self.session_secret=getsinglevalue(doc,'secret')
def getfriends(self):
  doc=self.sendrequest({'method':'facebook.friends.get',
                       'session_key':self.session_key,'call_id':callid( )})
  results=[]
  for n in doc.getElementsByTagName('result_elt'):
    results.append(n.firstChild.nodeValue)
  return results
def getinfo(self,users):
  ulist=','.join(users)
  fields='gender,current_location,relationship_status,'+\
         'affiliations,hometown_location'
  doc=self.sendrequest({'method':'facebook.users.getInfo',
  'session_key':self.session_key,'call_id':callid( ),
  'users':ulist,'fields':fields})
  results={}
  for n,id in zip(doc.getElementsByTagName('result_elt'),users):
     # Get the location
     locnode=n.getElementsByTagName('hometown_location')[0]
     loc=getsinglevalue(locnode,'city')+', '+getsinglevalue(locnode,'state')
# Get school
     college=''
     gradyear='0'
     affiliations=n.getElementsByTagName('affiliations_elt')
     for aff in affiliations:
# Type 1 is college
       if getsinglevalue(aff,'type')=='1':
         college=getsinglevalue(aff,'name')
         gradyear=getsinglevalue(aff,'year')
       results[id]={'gender':getsinglevalue(n,'gender'),
                   'status':getsinglevalue(n,'relationship_status'),
                   'location':loc,'college':college,'year':gradyear}
       return results

Try StartTransaction and CommitTransaction

Thank you! I'll surely try it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.