Thread: [SQLObject] queries with sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Flavio C. <fcc...@gm...> - 2005-10-28 09:16:56
|
I have been using SQLObject for writing to a mysql database for a while now= , and I am very happy with its very straightforward interface. Now I want to do some queries and I am facing some problems: My problem is as following: I have database tables created before by SQLObject. I Need to do the equivalent of a "show tables" SQL command to see what tables are available. Get a list of strings with the names of the tables in my database. Select one of these and check which columns they have(get a list of column names). I have no Idea of how to do this with SQLObject although this is a very basic thing in SQL. can anyone tell me how to accomplish this with SQLObject? thanks in advance, -- Fl=E1vio Code=E7o Coelho registered Linux user # 386432 --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |
From: Rene D. <re...@gm...> - 2005-10-28 09:32:07
|
Hey, I'm not sure if there is a way in sqlobject to do what you want. However you can still make sql queries with the connection. eg. db_connection =3D connectionForURI('your db connection string') rows =3D db_connection.queryAll('select * from sometable') Really handy for when sqlobject can't do what you want. It would be nice if this was in the documentation somewhere. Listed as a feature. On 10/28/05, Flavio Coelho <fcc...@gm...> wrote: > I have been using SQLObject for writing to a mysql database for a while n= ow, > and I am very happy with its very straightforward interface. > > Now I want to do some queries and I am facing some problems: > > My problem is as following: > I have database tables created before by SQLObject. > I Need to do the equivalent of a "show tables" SQL command to see what > tables are available. > Get a list of strings with the names of the tables in my database. Selec= t > one of these and check which columns they have(get a list of column names= ). > I have no Idea of how to do this with SQLObject although this is a very > basic thing in SQL. > > can anyone tell me how to accomplish this with SQLObject? > > thanks in advance, > > -- > Fl=E1vio Code=E7o Coelho > registered Linux user # 386432 > --------------------------- > Great spirits have always found violent opposition from mediocrities. The > latter cannot understand it when a man does not thoughtlessly submit to > hereditary prejudices but honestly and courageously uses his intelligence= . > Albert Einstein > |
From: Flavio C. <fcc...@gm...> - 2005-10-28 10:08:29
|
---------- Forwarded message ---------- From: Flavio Coelho <fcc...@gm...> Date: 28/10/2005 08:00 Subject: Re: [SQLObject] queries with sqlobject To: Rene Dudfield <re...@gm...> 2005/10/28, Rene Dudfield <re...@gm...>: > > > eg. > db_connection =3D connectionForURI('your db connection string') > rows =3D db_connection.queryAll('select * from sometable') Thanks, I didn't now that. I using MySQLdb for that now. But it would be nice if there was a way to do queries in an object style. In my problem, if I could create a SQlObject instance from a database table, I could just do = a dir(instance) to get column names instead of using the standard SQL query (show fields from my_table) on the connection. Really handy for when sqlobject can't do what you want. > > > It would be nice if this was in the documentation somewhere. Listed > as a feature. totally agree. Fl=E1vio On 10/28/05, Flavio Coelho <fcc...@gm... > wrote: > > I have been using SQLObject for writing to a mysql database for a while > now, > > and I am very happy with its very straightforward interface. > > > > Now I want to do some queries and I am facing some problems: > > > > My problem is as following: > > I have database tables created before by SQLObject. > > I Need to do the equivalent of a "show tables" SQL command to see what > > tables are available. > > Get a list of strings with the names of the tables in my database. > Select > > one of these and check which columns they have(get a list of column > names). > > I have no Idea of how to do this with SQLObject although this is a very > > basic thing in SQL. > > > > can anyone tell me how to accomplish this with SQLObject? > > > > thanks in advance, > > > > -- > > Fl=E1vio Code=E7o Coelho > > registered Linux user # 386432 > > --------------------------- > > Great spirits have always found violent opposition from mediocrities. > The > > latter cannot understand it when a man does not thoughtlessly submit to > > hereditary prejudices but honestly and courageously uses his > intelligence. > > Albert Einstein > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > -- Fl=E1vio Code=E7o Coelho registered Linux user # 386432 --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein -- Fl=E1vio Code=E7o Coelho registered Linux user # 386432 --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |
From: Oleg B. <ph...@ma...> - 2005-10-28 10:46:27
|
On Fri, Oct 28, 2005 at 08:01:52AM -0200, Flavio Coelho wrote: > If I could create a SQlObject instance from a database table class MyTable(SQLObject): class sqlmeta: fromDatabase = True Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Flavio C. <fcc...@gm...> - 2005-10-28 13:02:02
|
Does not really help, Since the database has multiple tables and I do not know the table name in advance. Since SQLObject requires the class name to correspond to the table name.... 2005/10/28, Oleg Broytmann <ph...@ma...>: > > On Fri, Oct 28, 2005 at 08:01:52AM -0200, Flavio Coelho wrote: > > If I could create a SQlObject instance from a database table > > class MyTable(SQLObject): > class sqlmeta: > fromDatabase =3D True > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > -- Fl=E1vio Code=E7o Coelho registered Linux user # 386432 --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |
From: Oleg B. <ph...@ph...> - 2005-10-28 13:08:58
|
On Fri, Oct 28, 2005 at 11:01:53AM -0200, Flavio Coelho wrote: > Since SQLObject requires the class name to > correspond to the table name.... It does not. See below. > 2005/10/28, Oleg Broytmann <ph...@ma...>: > > > > On Fri, Oct 28, 2005 at 08:01:52AM -0200, Flavio Coelho wrote: > > > If I could create a SQlObject instance from a database table > > > > class MyTable(SQLObject): > > class sqlmeta: > > fromDatabase = True class MyTable(SQLObject): class sqlmeta: table = "a_different_name" fromDatabase = True Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |