Forwarding to list. Please use REplyAll when responding to tutor messages.
On 04/08/16 09:19, Trevor H wrote:
> Hi Alan,
>
> Thank you for the reply. I'll try show the graphic as a website. Would
> I have to make the data entries as a model in Django?
>
I'm not a Django expert so don;t know
On 19/05/16 10:03, Crusier wrote:
> c.execute('''CREATE TABLE stocks
> (code text)''')
>
> # Insert a row of data
> List = ['1', '2', '3', '4', '5', '6', '7',
> '8', '9', '00010', '00011', '00012']
>
> c.executemany('INSERT INTO stocks VALUES
Crusier wrote:
> Dear Alan,
>
> I have read your web page and try to test thing out on SQLite.
>
> Attached is my code:
>
> import sqlite3
> conn = sqlite3.connect('example1.db')
> c = conn.cursor()
> c.execute('drop table if exists stocks')
> c.execute('''CREATE TABLE stocks
>
Dear Alan,
I have read your web page and try to test thing out on SQLite.
Attached is my code:
import sqlite3
conn = sqlite3.connect('example1.db')
c = conn.cursor()
c.execute('drop table if exists stocks')
c.execute('''CREATE TABLE stocks
(code text)''')
# Insert a row of data
On Tue, 3 May 2016, Crusier wrote:
I am just wondering if there is any good reference which I can learn how to
program SQLITE using Python
I can not find any book is correlated to Sqlite using Python.
"The Definitive Guide to SQLite" is about SQLite, but includes a chapter
on both PySQLite
Alan Gauld via Tutor wrote:
> On 13/05/16 21:25, Neil D. Cerutti wrote:
>
>> From your tutorial:
>>
>> query = '''INSERT INTO Address
>> (First,Last,House,Street,District,Town,PostCode,Phone)
>> Values ("%s","%s","%s","%s","%s","%s","%s","%s")''' %\
>>
On 13/05/16 21:25, Neil D. Cerutti wrote:
> From your tutorial:
>
> query = '''INSERT INTO Address
> (First,Last,House,Street,District,Town,PostCode,Phone)
> Values ("%s","%s","%s","%s","%s","%s","%s","%s")''' %\
> (first, last, house, street,
On 5/3/2016 11:40 AM, Alan Gauld via Tutor wrote:
On 03/05/16 10:09, Crusier wrote:
I am just wondering if there is any good reference which I can learn how to
program SQLITE using Python
I can not find any book is correlated to Sqlite using Python.
You can try my tutorial below.
On 03/05/16 10:09, Crusier wrote:
> I am just wondering if there is any good reference which I can learn how to
> program SQLITE using Python
>
> I can not find any book is correlated to Sqlite using Python.
You can try my tutorial below.
http://www.alan-g.me.uk/tutor/tutdbms.htm
If you want
Dear All,
I am just wondering if there is any good reference which I can learn how to
program SQLITE using Python
I can not find any book is correlated to Sqlite using Python.
Thank you
Regards,
Hank
___
Tutor maillist - Tutor@python.org
To
I was just looking at the sqlite3 docs at
https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3
and found the following cheery news:
Usually your SQL operations will need to use values from Python
variables. You shouldn’t assemble your query using Python’s string
On 14/08/15 19:40, boB Stepp wrote:
Instead, use the DB-API’s parameter substitution. Put ? as a
placeholder wherever you want to use a value, and then provide a tuple
of values as the second argument to the cursor’s execute() method...
This is not a Sqlite issue its true of any database.
I
On 8/14/2015 11:40 AM, boB Stepp wrote:
I was just looking at the sqlite3 docs at
https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3
and found the following cheery news:
Usually your SQL operations will need to use values from Python
variables. You shouldn’t
On 14Aug2015 13:40, boB Stepp robertvst...@gmail.com wrote:
I was just looking at the sqlite3 docs at
https://docs.python.org/3/library/sqlite3.html?highlight=sqlite#module-sqlite3
and found the following cheery news:
Usually your SQL operations will need to use values from Python
variables.
Hi,
I have a dictionary with keys as employee badges and values as their names.
Both key and value are strings.
I want to read the badges from a sql select and use that to look up the
names in the dictionary. But since the result is a tuple, it doesnt' work.
how can i overcome this?
1.
I think you are missing the fetch call. The cursor only executed your
query, but hasn't fetched any thing out.
On Tue, Jun 11, 2013 at 12:20 PM, Khalid Al-Ghamdi emailkg...@gmail.comwrote:
Hi,
I have a dictionary with keys as employee badges and values as their
names. Both key and value are
Alan Gauld wrote:
On 18/01/13 18:11, Roger wrote:
At the moment this works to search for everything beginning with A
sql = SELECT * FROM plants WHERE genus LIKE 'A%';
cursor.execute(sql);
SQLlite supports a form of format string where you put in some magic
charactrs then provide
On 18/01/13 18:11, Roger wrote:
At the moment this works to search for everything beginning with A
sql = SELECT * FROM plants WHERE genus LIKE 'A%';
cursor.execute(sql);
SQLlite supports a form of format string where you put in some magic
charactrs then provide arguments which SQLLite will
On 27 January 2013 18:21, Alan Gauld alan.ga...@btinternet.com wrote:
On 18/01/13 18:11, Roger wrote:
At the moment this works to search for everything beginning with A
sql = SELECT * FROM plants WHERE genus LIKE 'A%';
cursor.execute(sql);
SQLlite supports a form of format string where you
file:///home/alang/Documents/HomePage/tutor/tutdbms.htm
You might have better luck using this link:
http://www.alan-g.me.uk/tutor/tutdbms.htm
Oops, thanks for spotting that!
I keep two copies of the site open in separate browser tabs and mistakenly used
the local
file version when
Hello,
I am very new to python. Wrote a small program to use on my android phone using
pickle/shelve to access data.
That worked fine but i realised it would be better to use sqlite as a database
to more easily modify the data.
I havent got a clue about sqlite, have a book but cant find the
Hello,
I am very new to python.
Wrote a small program to use on my android phone
using pickle/shelve to access data.
That worked fine but i realised it would be better to use sqlite as a
database to more easily modify the data.
I havent got a clue about sqlite, have a book but cant find
Roger Shaw wrote:
Hello,
I am very new to python.
Wrote a small program to use on my android phone using pickle/shelve to
access data.
That worked fine but i realised it would be better to use sqlite as a
database to more easily modify the data.
I havent got a clue about sqlite,
Date: Tue, 20 Jul 2010 07:28:45 +0200
From: cwi...@compuscan.co.za
To: pine...@hotmail.com
CC: tutor@python.org
Subject: Re: [Tutor] SQLite database locked problem
On 20/07/2010 06:48, Che M wrote:
I'm
using an SQLite3 database (with Python 2.5) and every so often
I'm using an SQLite3 database (with Python 2.5) and every so often the
application crashes or hangs because somewhere there is this error, or
something like it:
OperationalError: database is locked.
This is probably because I am viewing and sometimes changing the database
through SQLite
://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
SQLite
Benno Lang wrote:
On 10 March 2010 11:37, Alan Harris-Reid aharrisr...@googlemail.com wrote:
Hi there,
I am using the sqlite3 module with Python 3.1, and have some code which goes
something like as follows...
import sqlite3
con = sqlite3.connect('MyDatabase.db')
try:
execresult =
Sander Sweers wrote:
- Original message -
I am using the sqlite3 module with Python 3.1, and have some code which
goes something like as follows...
import sqlite3
con = sqlite3.connect('MyDatabase.db')
try:
execresult = con.execute('INSERT INTO MyTable (field_name) VALUES
On 10 March 2010 21:02, Alan Harris-Reid aharrisr...@googlemail.com wrote:
Maybe I have misunderstood you, but I always thought that the 'finally'
section was run even if the 'try' section is successful, in which case I
would not want a rollback.
I was thinking something like this.
import
Hi there,
I am using the sqlite3 module with Python 3.1, and have some code which
goes something like as follows...
import sqlite3
con = sqlite3.connect('MyDatabase.db')
try:
execresult = con.execute('INSERT INTO MyTable (field_name) VALUES
(MyValue)')
con.commit()
except:
On 10 March 2010 11:37, Alan Harris-Reid aharrisr...@googlemail.com wrote:
Hi there,
I am using the sqlite3 module with Python 3.1, and have some code which goes
something like as follows...
import sqlite3
con = sqlite3.connect('MyDatabase.db')
try:
execresult = con.execute('INSERT
- Original message -
I am using the sqlite3 module with Python 3.1, and have some code which
goes something like as follows...
import sqlite3
con = sqlite3.connect('MyDatabase.db')
try:
execresult = con.execute('INSERT INTO MyTable (field_name) VALUES
(MyValue)')
Dear List Members,
I need help in a mystic problem (I hope just for me) with python and
sqlite3.
Running enviroment:
OS: Windows 2003 ENG 64bit, Windows XP HUN 32bit
Python: ActiveState Python 2.6.4 32bit (It's a must because of PyWin
extension in the future and I didn't have any issue with it
2010/1/29 BOBÁK Szabolcs szabolcs.bo...@gmail.com:
This also works, but this not:
sql_command_stat = 'SELECT COUNT(lastmoddate) FROM
'+sql_tablename_orig+'WHERE lastmoddate '+str(lastmod_date1)
sql_cursor.execute(sql_command_stat)
This was my original try, but tried various in various
Dear Hugo,
Thank you for your fast help and the sharp eyes.
I was almost hopeless.
It is working now, but only with the first formula, and I also voted to the
third one, so I will try a little bit more.
Thank you very much!
2010. január 29. 17:53 Hugo Arts írta, hugo.yo...@gmail.com:
It's working fine now, but actually I didn't write exactly what you
suggested.
The commit method belongs to the connection, not to the cursor. Therefore,
in my script it should be conn.commit().
Whoops, you're quite right. Went a little too fast there. :D
Che
Hi tutors,
I've got a functions that should update an sqlite database, among other
things. However the database doesn't get updated. When used in isolation,
the update statement works fine. What am I doing wrong?
Below is the function. The whole script can be found at
I've got a functions that should update an sqlite database, among other
things. However
the database doesn't get updated. When used in isolation, the update
statement works
fine. What am I doing wrong?
Below is the function. The whole script can be found at
Thanks a lot, Che! It's working fine now.
On Sun, Nov 8, 2009 at 9:13 PM, Che M pine...@hotmail.com wrote:
I've got a functions that should update an sqlite database, among other
things. However
the database doesn't get updated. When used in isolation, the update
statement works
fine.
It's working fine now, but actually I didn't write exactly what you
suggested. The commit method belongs to the connection, not to the cursor.
Therefore, in my script it should be conn.commit().
On Sun, Nov 8, 2009 at 9:15 PM, Che M pine...@hotmail.com wrote:
I've got a functions that should
Rich,
thanks a lot -- that was the problem.
David
Rich Lovely wrote:
2009/7/25 David ld...@gmx.net:
Dear tutors,
I am trying to teach myself the way Python's works with databases.
I decided to start with SQLite, and am looking at Summerfield's
'Programming in Python 3'.
I got a code
Dear tutors,
I am trying to teach myself the way Python's works with databases.
I decided to start with SQLite, and am looking at Summerfield's
'Programming in Python 3'.
I got a code snippet that I don't fully understand (the comments are mine):
def get_and_set_director(db, director):
#
2009/7/25 David ld...@gmx.net:
Dear tutors,
I am trying to teach myself the way Python's works with databases.
I decided to start with SQLite, and am looking at Summerfield's
'Programming in Python 3'.
I got a code snippet that I don't fully understand (the comments are mine):
def
.
The code is in my recent post (Subject: pysqlite and functions) with a new
problem ie. the code works as-is but not within a def function.
Dinesh
..
Date: Fri, 11 Apr 2008 13:20:12 +0100
From: Tim Golden [EMAIL PROTECTED]
Subject: Re: [Tutor
Dinesh B Vadhia [EMAIL PROTECTED] wrote
I'm using the LIKE operator to match a pattern against a string
using this SELECT statement:
for row in con.execute(
SELECT column
FROM table
WHERE string LIKE '%q%'
limit 25):
With q=dog as a test example, I've tried '$q%', '%q%', '%q'
Simone wrote:
In Python the symbol '%' in a string is a special char: you use it, for
instance, to place a variable inside a string.
For completeness, it's worth mentioning in passing that % is only
special when you're doing string formatting. It's not otherwise
special in strings.
However,
i forgot to mention that you need to try your sql commands out of your
script before trying them inside,
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I m not sure this is your case but i believe you are missing the
cur.fetchall() command which does fetch data from sql db
i suggest you put a print statement for every data you use in your program
that way you know whats empty whats not...
here is example of MySQLdb process:
Dinesh B Vadhia ha scritto:
The second problem is that I'm using the LIKE operator to match a
pattern against a string but am getting garbage results. For example,
looking for the characters q='dog' in each string the SELECT statement
is as follows:
for row in con.execute(SELECT
Okay, I've got this now:
con = sqlite3.connect(:memory:)
cur = con.cursor()
cur.execute(CREATE TABLE db.table(col.a integer, col.b text))
con.executemany(INSERT INTO db.table(col.a, col.b) VALUES (?, ?), m)
con.commit()
for row in con.execute(SELECT col.a, col.b FROM db.table):
Dinesh B Vadhia wrote:
Okay, I've got this now:
con = sqlite3.connect(:memory:)
cur = con.cursor()
cur.execute(CREATE TABLE db.table(col.a integer, col.b text))
con.executemany(INSERT INTO db.table(col.a, col.b) VALUES (?, ?), m)
con.commit()
for row in con.execute(SELECT col.a, col.b
Dinesh B Vadhia [EMAIL PROTECTED] wrote
As Python/pysqlite stores the items in the db.table as unicode
strings, I've also run the code with q=udog but get the same
error. Same with putting the q as a tuple ie. (q) in the Select
(q) is not a tuple, it is a variable surrounded by quotes.
I'm reading a text file into an in-memory pysqlite table. When I do a SELECT
on the table, I get a 'u' in front of each returned row eg.
(u'QB VII',)
(u'Quackser Fortune Has a Cousin in the Bronx',)
I've checked the data being INSERT'ed into the table and it has no 'u'.
The second problem
Dinesh B Vadhia [EMAIL PROTECTED] wrote
I'm reading a text file into an in-memory pysqlite table.
When I do a SELECT on the table, I get a 'u' in front of
each returned row eg.
(u'QB VII',)
The u is not part of the data its Python telling you that
the string is Unicode.
The second
Hi, I am trying to simply create an SQLite database with Python. I find
that when I try to create a new database file, *sometimes* it lets me do it,
and sometimes it doesn't, and the only thing I am changing is the name of
the database. I am baffled as to why some names appear to work and
Che M [EMAIL PROTECTED] wrote
don't. For example, this will create a brand new database on the
desktop:
conn = sqlite3.connect('C:\Documents and
Settings\user\Desktop\mydatabase.db')
But running *this*--only thing different is the database's
name--gives the
error, as shown:
conn =
Che M schreef:
Hi, I am trying to simply create an SQLite database with Python. I find
that when I try to create a new database file, *sometimes* it lets me do it,
and sometimes it doesn't, and the only thing I am changing is the name of
the database. I am baffled as to why some names
Thank you Alan and Roel for the insight, and Roel thank you for all the
suggested ways to get around it. It's always nice when something goes from
making no sense to making complete sense in a snap.
Che
_
Booking a flight? Know
On Wed, 1 Aug 2007, Terry Carroll wrote:
Does the ? approach not work with PRAGMA commands or something; or am I
doing this wrong?
Just a quick follow-up on this, in case anyone else cares. My conclusion
is that it's not supported. Googling around I found this pysqlite bug
report:
I'm using sqlite for the first time, so I'm not sure whether I'm trying to
do something unsupported. or whether I'm trying to do something that's
supported, but doing it wrong.
I want to get information about a table in my database. The variable
tablename holds the name of the table, and
I'm not sure about PRAGMA, but you can do introspection in sqlite by
examining the table 'sqlite_master'.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Thu, 2 Aug 2007, John Fouhy wrote:
I'm not sure about PRAGMA, but you can do introspection in sqlite by
examining the table 'sqlite_master'.
Thanks. That's how I get the table names, actually. But it doesn't give
the column names.
It does give the SQL used to create the table, so I
Terry Carroll wrote:
GET_TABLE_INFO_COMMAND = PRAGMA TABLE_INFO(?)
pragma_cmd = GET_TABLE_INFO_COMMAND
field_data = self.dbconn.execute(pragma_cmd, (tablename))
I get the error:
sqlite3.OperationalError: near ?: syntax error
Some of the variations included using tablename or
On 03/08/07, Terry Carroll [EMAIL PROTECTED] wrote:
On Thu, 2 Aug 2007, John Fouhy wrote:
I'm not sure about PRAGMA, but you can do introspection in sqlite by
examining the table 'sqlite_master'.
Thanks. That's how I get the table names, actually. But it doesn't give
the column names.
64 matches
Mail list logo