Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 03:21, Marilyn Davis wrote: > connection.execute("SELECT * FROM BRIGHTEST") > > returns a , not a regular python > sequence. Pretty much everything inn SQL land uses cursor objects. It's why best practice creates an explicit cursor for executing statements rather than the impl8ici

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-19 Thread Marilyn Davis
Thank you Alan, Steven and Peter, So, this call: connection.execute("SELECT * FROM BRIGHTEST") returns a , not a regular python sequence. I did not know that. And, the connection must still be alive when you iterate it. That is a very important tidbit of info. The fix is to listify the Curso

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-18 Thread Peter Otten
Marilyn Davis wrote: > #!/usr/bin/env python3 > """ > Hello Tutors, > > I can't figure out why the FillWithStars() function puts Canopus in the db > twice. > > What am I missing? > > Thank you for any help. > > Marilyn Davis > > p.s. That Reset(db_name) is in there so that you can run it over

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-17 Thread Steven D'Aprano
I made one more diagnostic change to your script, changing the FillWithStars function to this: def FillWithStars(): with sqlite3.connect("stars.db") as connection: connection.executescript(""" CREATE TABLE brightest( name, constellation,

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-17 Thread Steven D'Aprano
On Mon, Apr 17, 2017 at 04:36:50PM -0700, Marilyn Davis wrote: > #!/usr/bin/env python3 > """ > Hello Tutors, > > I can't figure out why the FillWithStars() function puts Canopus in the db > twice. Good question. And thank you for providing a really well-written, simple, clear script that we ca

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-17 Thread Alan Gauld via Tutor
On 18/04/17 00:36, Marilyn Davis wrote: > #!/usr/bin/env python3 > """ > Hello Tutors, > > I can't figure out why the FillWithStars() function puts Canopus in the db > twice. > > What am I missing? I don;t know but I converted your script into the more conventional form and it worked. it was the

[Tutor] sqlite3 making a spurious duplicate?

2017-04-17 Thread Marilyn Davis
#!/usr/bin/env python3 """ Hello Tutors, I can't figure out why the FillWithStars() function puts Canopus in the db twice. What am I missing? Thank you for any help. Marilyn Davis p.s. That Reset(db_name) is in there so that you can run it over and over if you want. --- """ import os, sqlite3