On 17/10/2015 20:42, andybrookestar--- via Python-list wrote:
i'm mainly a PHP man but playing with python recently!
I have a very small class that retrieves data from a very small sqlite3 db called
encyclopedia,which has a table called wiki & two field called one & two (yes I
know - no imagination, I should get out more!):
import sqlite3
class do:
def doConn(self):
self.conn = sqlite3.connect('encyclopedia')
self.myText = "sulphur"
print "Opened database successfully";
cursor = self.conn.execute("SELECT * from wiki WHERE one LIKE 'alan
turing' ")
for row in cursor:
print "first field = ", row[0]
print "second filed = ", row[1]
print "Operation done successfully";
self.conn.close()
x = do()
x.doConn()
#the above works when I pass a string as an argument such as the above where I
use 'alan turing'
i want to pass an argument as a variable which in PHP could be $somevariable or
$this->somevariable which say equal "some string"
I have played around with passing self.myText instead of 'alan turing' and it
doesn't like it- oh Alan I wish you were here!
From https://docs.python.org/3/library/sqlite3.html
t = ('RHAT',)
c.execute('SELECT * FROM stocks WHERE symbol=?', t)
print(c.fetchone())
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list