SQL package

J

Juan

Hi

I am trying to write a little a script that can be configurable. This
script should access to a database, that can be of any type (MySQL,
Postgres, SQLite, MS, etc).It has only to perform 2 or 3 simple plain
SQL queries. Hi have tested SQLAlchemy, and it is great, but too much
for my requirements, and I don't have any object relation with the
database tables. All I need is to access any database type in the same
way (mysql://user:pass@localhost/database, pgsqll://user:pass@localhost/database,
....) and run some basic queries. I have searched for this, but I have
not found any solution. Could you help me please?

If not, how can I run a simple query in SQLAlchemy? And iter the
results? I have tried this without success:

engine = create_engine('postgres://user:pass@localhost/database',
echo=True)
results = engine.execute("SELECT * FROM TABLE")
for result in results:
print result
 
D

Diez B. Roggisch

Juan said:
Hi

I am trying to write a little a script that can be configurable. This
script should access to a database, that can be of any type (MySQL,
Postgres, SQLite, MS, etc).It has only to perform 2 or 3 simple plain
SQL queries. Hi have tested SQLAlchemy, and it is great, but too much
for my requirements, and I don't have any object relation with the
database tables. All I need is to access any database type in the same
way (mysql://user:pass@localhost/database, pgsqll://user:pass@localhost/database,
...) and run some basic queries. I have searched for this, but I have
not found any solution. Could you help me please?

If not, how can I run a simple query in SQLAlchemy? And iter the
results? I have tried this without success:

engine = create_engine('postgres://user:pass@localhost/database',
echo=True)
results = engine.execute("SELECT * FROM TABLE")
for result in results:
print result

sqlalchemy is the way to go, and you should consider actually reading
the documentation - the above clearly shows that you didn't.

http://www.sqlalchemy.org/docs/05/sqlexpression.html

Here you can see what is needed:
 
D

Diez B. Roggisch

Juan said:
Hi

I am trying to write a little a script that can be configurable. This
script should access to a database, that can be of any type (MySQL,
Postgres, SQLite, MS, etc).It has only to perform 2 or 3 simple plain
SQL queries. Hi have tested SQLAlchemy, and it is great, but too much
for my requirements, and I don't have any object relation with the
database tables. All I need is to access any database type in the same
way (mysql://user:pass@localhost/database, pgsqll://user:pass@localhost/database,
...) and run some basic queries. I have searched for this, but I have
not found any solution. Could you help me please?

If not, how can I run a simple query in SQLAlchemy? And iter the
results? I have tried this without success:

engine = create_engine('postgres://user:pass@localhost/database',
echo=True)
results = engine.execute("SELECT * FROM TABLE")
for result in results:
print result

Please read the documentation of sqlalchemy:

http://www.sqlalchemy.org/docs/05/sqlexpression.html

There is a very comprehensive example on that site what you should be
able to follow.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top