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 7608763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:00:06+00:00 2026-05-31T01:00:06+00:00

I run the following code db = create_engine(‘sqlite:///tracking_test.db’) db.echo= True metadata = MetaData(db) session

  • 0

I run the following code

db = create_engine('sqlite:///tracking_test.db')
db.echo= True
metadata = MetaData(db)
session = create_session(bind=db)
#define tables, if they exist sqlalchemly will find them and sycn otherwise they will be created
delivered= Table('delivered', metadata,
    Column('delivered_id',Integer,primary_key=True),
    Column('domain',String(200)),
    Column('path',String(500)),
    )

class Delivered(object):        
    def __init__(self,obj):
        self.domain=u'%s' % obj.get("dm","")
        self.path=u'%s' % obj.get("pth","")


report1t = Table('clicked', metadata,
    Column('clicked_id',Integer,primary_key=True),
    Column('domain',String(200)),
    Column('path',String(500)),

)

class report1(object):
    def __init__(self,obj):
        self.domain=u'%s' % obj.get("dm","")
        self.path=u'%s' % obj.get("pth","")


metadata.create_all()
mapper(report1, report1t)
mapper(Delivered,delivered)
result= {}#some dict
newT = Delivered(result)
if newT:
    session.add(newT)
    session.commit()
    session.flush()

And I get this error
sqlalchemy.exc.InvalidRequestError: No transaction is begun.

the session dict say:

{'autocommit': True, 'autoflush': False, 'transaction': None, 'hash_key': 4317750544, 'expire_on_commit': False, '_new': {<sqlalchemy.orm.state.InstanceState object at 0x101a79ad0>: <__main__.adDelivered object at 0x101a799d0>}, 'bind': Engine(sqlite:///adtracking_test.db), '_deleted': {}, '_flushing': False, 'identity_map': {}, 'dispatch': <sqlalchemy.event.SessionEventsDispatch object at 0x101a82f90>, '_enable_transaction_accounting': True, '_identity_cls': <class 'sqlalchemy.orm.identity.WeakInstanceDict'>, 'twophase': False, '_Session__binds': {}, '_query_cls': <class 'sqlalchemy.orm.query.Query'>}

Any one know what I am doing wrong?

Thanks,
CG

  • 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-31T01:00:08+00:00Added an answer on May 31, 2026 at 1:00 am

    It would be helpful if you post the full traceback. However, I think the problem is in the way you create the session. I think that you should be using sessionmaker rather than create_session (I’ve never seen that function before, and I don’t see it documented anywhere). sessionmaker creates a new Session class, which you need to instantiate. So:

    Session = sessionmaker(bind=db)
    session = Session()
    ...
    session.add(newT)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run the following code to test copying a directory, I get a
I want to run the following code: ajaxUpdate(10); With a delay of 1 second
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
When I run the following code, I get the exception below: ''# NOTE: ExcelApp
When I run the following code, it only seems to be downloading the first
When I try to run the following code (from the REPL) in Clojure: (dotimes
I am trying to run the following code from within Eclipse: Process process =
Why whenever I compile and run the following code in Visual Studio 2008: double
if I compile (under G++) and run the following code it prints Foo::Foo(int). However
I want to run the following jquery code on every page in my website.

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.