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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:33+00:00 2026-06-18T06:31:33+00:00

I would like to use SQLAlchemy ORM not only for querying a database, but

  • 0

I would like to use SQLAlchemy ORM not only for querying a database, but also to create the tables. So I connect to the empty schema of my database:

engine = create_engine(connection_string)
Base = declarative_base()

I have a few classes which looks similar to the following example:

class SomeClass(Base):
    __tablename__= 'SomeClass'
    id = Column(Integer, primary_key=True, auto_increment=True)
    name = Column(String(50))

    def __init__(self, name):
        self.name = name

To create the database I call:

Base.metadata.create_all(engine)

This works fine – the FIRST time. If I now drop the tables manually from the database OR calling Base.metadata.drop_all() and restart the script (hence call create_all again) I get an error that my tables already exists:

sqlalchemy.exc.OperationalError: (OperationalError) (1050, "Table 'someclass' already exists") 

I can clearly say, that this is not true. I am able to create a table with the same name using CREATE TABLE from my CLI tool AND also if I now stop the database daemon and start it again, I will be able to create the tables again using create_all.

So I guess this has something to do with the connection between SQLAlchemy and the database. Obviosly SQLAlchemy thinks the table still exists after I dropped it, which is not true. But if I try to query this none existing table it will tell me, that the table does not exist.

I googled around but wasn’t able to find an explanation for this behavior. I do not use SQLAlchemy too often, so maybe I’m simply not deep enough into it, to understand the problem.

Anyway I would be thankful to get a hint.

I’m using Python 2.7.3 and MySQL 5.1.47 and SQLAlchemy 0.8.0b2

PS: Using Postgres I’ve never suffered from such an issue.

  • 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-06-18T06:31:34+00:00Added an answer on June 18, 2026 at 6:31 am

    I’ve fixed the issue by upgrading to MySQL 5.1.66. Note that I did not just upgrade the old instance, but unistalled it completely from my system and installing the new version from scratch. Thus I am still not able to tell if the issue was due to a misconfiguration of my old installation or just a bug.

    However, now everything works fine.

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

Sidebar

Related Questions

I would like to use the logout function from Django but not sure how
I have an array of Integers in Java, I would like use only a
I would like to use the MFMailComposeViewController mailComposeDelegate property with completion block syntax, but
i would like use a variable session ($_session) but it doesn't work in Drupal
Possibly really simple question, but I'm new to IronPython. I would like use IronPython
I would like to document a set of sqlalchemy database classes. I have followed
I'm trying to use SqlAlchemy to make Sqlite database tables inside of Pylons. I'm
I would like to use Pylons with Elixir, however, I am not sure what
I would like to use R to extract the speaker out of scripts formatted
I would like to use Maven's password encryption such as it uses for nodes

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.