2

I have created a table (MySQL 5.1)

from sqlalchemy import *
def get():
 db = create_engine('mysql://user:password@localhost/database')
 db.echo = True
 metadata = MetaData(db)
 feeds = Table('feeds', metadata,
 Column('id', Integer, primary_key=True),
 Column('title', String(100)),
 Column('link', String(255)),
 Column('description', String(255)),
 )
 entries = Table('entries', metadata,
 Column('id', Integer, primary_key=True),
 Column('fid', Integer),
 Column('url', String(255)),
 Column('title', String(255)),
 Column('content', String(5000)),
 Column('date', DateTime),
 )
 feeds.create()
 entries.create()

But when I try to query it:

from sqlalchemy import *
db = create_engine('mysql://user:password@localhost/database')
metadata = MetaData(db)
feeds = Table('feeds', metadata)
s = feeds.select()
result = db.execute(s)

I get an error on the result = db.execute(s) line indicating the following:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM feeds' at line 2") 'SELECT \nFROM feeds' ()

I'm obviously new to SQLAlchemy, and I have no idea what I'm doing wrong, despite having googled every tutorial on the web and changed this a million times. Any help?

Rup
34.6k9 gold badges86 silver badges119 bronze badges
asked Sep 13, 2010 at 1:00

2 Answers 2

1

I suspect Table.select() is only for selecting specific columns. For SELECT *, the expression language tutorial uses this syntax instead:

from sqlalchemy.sql import select
s = select([feeds])
result = db.execute(s)
answered Sep 13, 2010 at 2:54
1
  • Any progress? We can't really help you more if you don't respond to our first suggestions. Commented Sep 20, 2010 at 9:44
0

there's something missing probably from your feeds.select() call, I'd have another look at the API documentation for this function.

answered Sep 13, 2010 at 1:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.