0

I am trying to run through the SQL Alchemy tutorials and I am having trouble creating tables. I am getting this error (full Traceback here)

sqlalchemy.exc.InternalError: (InternalError) (1, "Can't create/write to file '/mysqltmp/#sql_a5f_0.MYI' (Errcode: 13)") 'DESCRIBE ``users`` ()

When I try to run the following code

from sqlalchemy import create_engine, MetaData
from ers_config import database_connect_string
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    fullname = Column(String)
    password = Column(String)

    def __repr__(self):
       return "<User(name='%s', fullname='%s', password='%s')>" % (
                            self.name, self.fullname, self.password)

ed_user = User(name='ed', fullname='Ed Jones', password='edspassword')
my_engine = create_engine(database_connect_string)
Session = sessionmaker(bind=my_engine)
my_session = Session()
Base.metadata.create_all(my_engine)

This same error happens whether I am inside my virtual environment or not

Brian Leach
  • 3,974
  • 8
  • 36
  • 75
  • Looks related: [How do I stop "Can't create/write to file" (Errcode: 2) in MySQL?](http://stackoverflow.com/q/13432003), [MySQL Error : Can't create/write to file '/var/mysqltmp/#sql\_1fbd\_0.MYI' (Errcode: 13)](http://stackoverflow.com/q/8114024), [MySQL: Can't create/write to file '/tmp/#sql\_3c6\_0.MYI' (Errcode: 2) - What does it even mean?](http://stackoverflow.com/q/11997012) – Martijn Pieters Jun 01 '14 at 01:19

1 Answers1

0

This issue was created by the fact that I had recently moved my My SQL temporary folder. My /tmp folder was quickly filling up (as a result of other operations), so I moved it by pointing to a folder specified in the /etc/my.cnf file.

I added a line at the bottom that looks like: tmpdir=/home/arguably/tmp/mysqltmp

Then, the error was coming from the fact that the file permissions on that file were not correct.

I used chmod 1777 /home/arguably/tmp/mysqltmp and the issue was solved.

This information was gleaned from trolling the swamps of information, I am still unclear what that first "1" in the 1777 command is for.

Brian Leach
  • 3,974
  • 8
  • 36
  • 75