Every time i retrieve information from the database it adds in " u'
string' " even though it is saved correctly in the database once i
retrieve it it contains this annotation.

original in db:
11408855402054064613470328848369

returned from db:
u'11239254724221911250033019109105'

Is there someway of removing this ? Is it possibly because i am using
sqlLite ?

In case you want to see the code...

from sqlalchemy import *

db = create_engine('sqlite:///pub_db.db')
db.echo = True
metadata = BoundMetaData(db)

#table
pubmed_table = Table('pubmed_table', metadata,
    Column('entry_id', Integer, primary_key=True),
    Column('title', String),
    Column('authors', String),
    Column('source', String),
    Column('abstract', String),
    Column('search_term', String),
    )
pubmed_table.create()


#create a object mapper
class PubMedTable(object):
        def _init_(self,entry_id,title,authors,source,abstract,search_term):
                self.entry_id
                self.title
                self.authors
                self.source
                self.abstract
                self.search_term
        def __repr__(self):
                return '%r|%r|%r|%r|%r|%r'
%(self.entry_id,self.title,self.authors,self.source,self.abstract,self.search_term)
pubmed_table_mapper = mapper(PubMedTable,pubmed_table)


session = create_session()
session


#create function to retrieve detail about an article and diplay this
information on screen

def get_details(id_value):
        result = session.query(PubMedTable).select_by(entry_id=id_value)

        for res in result:
                        print 'Article Details::'
                        print '=================\n\n'

  #here i create a list using the '|' seperator i put into the return
statement in the class

                        res1 =str(res)
                        pubmed_entry = res1.split('|')

   #here i attempt to remove these extra characters

                        title = pubmed_entry[1].split('\'')
                        source = pubmed_entry[3].split('\'')
                        abstract = pubmed_entry[4].split('\'')
                        abstract = str(abstract[1])
    #print results
                        print 'Number:',pubmed_entry[0],'\n'
                        print 'Title:',title[1],'\n'
                        print 'Authors:',pubmed_entry[2],'\n'
                        print 'Source:',source[1],'\n'
                        print 'Abstract\n'
                        print '--------\n'
                        print abstract,'\n'


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---

Reply via email to