Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:43:28+00:00 2026-05-22T22:43:28+00:00

I want to send a session object of sqlalchemy to a function of another

  • 0

I want to send a session object of sqlalchemy to a function of another class .

From class OraDialog‘s function oraconnect to class oraconn‘s assign function .

Actually My need is to use the session object in oraconn‘s another function map

I can’t send the session object directly to map function because it is a slot – it is triggered before .
I intended to define the assign function primarily to get the session object.

The Error : ( including print statements )

<sqlalchemy.orm.session.Session object at 0x030808F0>
<sqlalchemy.orm.session.Session object at 0x030808F0>
This is in assign
None
This is in map
Traceback (most recent call last):
File "C:\Users\Arul\Desktop\dbvis\oraconn.py", line 44, in map
for t in self.s.query(tables):
AttributeError: 'NoneType' object has no attribute 'query'

The oraconn class’s assign and map functions :

def assign(self,s):
    self.s=s
    print self.s
    print "This is in assign"
def map(self):
    print self.s
    print "This is in map"
    self.table_no=0
    for t in self.s.query(tables):
        self.table_no=self.table_no+1
        table_list.append(t.table_name)
    self.item=QtCore.QStringList()
    for c in self.s.query(columns):
        self.item.append(c.column_name)
    self.ui.list_col.addItems(self.item)

SO ,
The assign function receives the object properly . But the map function can’t use it – It says Nonetype

My Question :
Two functions of same class can’t use an object ?

I must have done something silly – so plz point out……

( I’m using windows7 / python 2.6 / PyQt4 /sqlalchemy /cx_oracle)

Edit :
The calling class :

class OraDialog(QtGui.QDialog):
def __init__(self,parent=None):
    QtGui.QDialog.__init__(self,parent)
    self.odia=Ui_Dialog()
    self.odia.setupUi(self)
    self.uiobj=oraconn()
    QtCore.QObject.connect(self.odia.but_con,QtCore.SIGNAL('clicked()'),self.uiobj.oraconnect)
def oraconnect(self):
    self.setVisible(0)
    eng_str="oracle://"+self.odia.line_user.text()+":"+self.odia.line_pass.text()+"@localhost:1521/"+self.odia.line_sid.text()+"?mode="+self.odia.line_role.text()
    engine_str=str(eng_str)
    engine=create_engine(engine_str)
    Session=sessionmaker(engine)
    self.s=Session()
    print self.s

Problem Solved :
The problem is – i’ve created two instances and passed from one to another .

Corrected code :

oraconn.assign(myapp,self.s)

where
oraconn -> class
assign -> function of oraconn
myapp -> instance of oraconn , declared for main application
self.s -> the argument i wanted to pass

Thank you Kirk ….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:43:29+00:00Added an answer on May 22, 2026 at 10:43 pm

    If you’re using Qt, then this is likely a GUI app. Maybe there are threading issues; maybe self refers to different objects. It’s hard to tell with only what you’ve given us. Before you go any further, add:

    print self
    

    near the top of each method. At least then you can confirm whether both are operating on the same object.


    In OraDialog.init, you’re saying self.uiobj=oraconn(). Is that the object that’s giving you problems? If so: notice that you’re creating at as an instance variable, so that each OraDialog object has a different .uiobj object. Could you try making that a class variable by writing:

    class OraDialog(QtGui.QDialog):
        uiobj = oraconn()
        def __init__() [...]
    

    instead? That is, define uiobj as belonging to all instances of the class, not just one instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that I want to send to another device via bluetooth.
I want to send email from a Ruby application. Is there a call in
I just want to send SMS from my web application in PHP. Can anyone
For testing purposes I want send mail to my localhost user account rather than
I want so send every week an update by email. But Im afraid that
I want to send an array constructed in javascript with the selected values of
I want to send a message to a thread and handle it in the
I want to send some strings in a list in a POST call. eg:
I want to send an Email message after a page is returned to the
I want to send a URI as the value of a query/matrix parameter. Before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.