Hi Rüdiger :)

Rüdiger Härtel wrote:
> Here is the kexi project.
> 
> Am Freitag 07 März 2008 14:03:45 schrieben Sie:
>> Rüdiger Härtel said the following, On 2008-03-07 13:52:
>> > I want to write a script to query some data from my db.
>> >
>> > the following works:
>> >
>> > cursor = connection.executeQueryString("SELECT * from emp where country
>> > = 'Germany'")
>> > ...
>> >
>> > but this does not work
>> >
>> > country = self.countries.get()
>> > sqlStmt = "SELECT * from emp where country = %s" % country
>> > cursor = connection.executeQueryString(sqlStmt)

probably the country variable does contain the wrong value. Following works 
fine with your testdb;

import kexiapp
keximainwindow = kexiapp.get("KexiAppMainWindow")
connection = keximainwindow.getConnection()
country="Germany"
sqlStmt = 'SELECT * from tabelle1 WHERE country = \'%s\';' % country
cursor = connection.executeQueryString(sqlStmt)
if not cursor:
        raise "No cursor"
while not cursor.eof():
        for i in range( cursor.fieldCount() ):
                print "%s %s" % (str(i), cursor.value(i))
        cursor.moveNext()
_______________________________________________
Kexi mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kexi

Reply via email to