All:
I am using Python to read some records from the MySQL database. I am
using the mysqldb library, and things are working well.
Now, I would like to pass back the results of the query to a Web-based
front end, and I would like to use JSON. Is there a library/example of
creating a JSON array from a mysqldb row or row set?
Thanks,
jpuopolo 4 5037
jpuopolo wrote:
All:
I am using Python to read some records from the MySQL database. I am
using the mysqldb library, and things are working well.
Now, I would like to pass back the results of the query to a Web-based
front end, and I would like to use JSON. Is there a library/example of
creating a JSON array from a mysqldb row or row set?
Thanks,
jpuopolo
Google turns up several high quality links, just look for 'python json'.
-Larry
On Aug 26, 3:15*pm, Larry Bates <larry.ba...@vitalEsafe.comwrote:
jpuopolo wrote:
All:
I am using Python to read some records from the MySQL database. I am
using the mysqldb library, and things are working well.
Now, I would like to pass back the results of the query to a Web-based
front end, and I would like to use JSON. Is there a library/example of
creating a JSON array from a mysqldb row or row set?
Thanks,
jpuopolo
Google turns up several high quality links, just look for 'python json'.
-Larry
Larry:
Thank you for the reply. Unfortunately, some of the libs the Google
search returns bail when
converting a database record into a JSON object. I may be using it/
them incorrectly, so I'll post
results to this newsgroup accordingly.
Best,
John
There's always the naive option.
query = ('species', 'lifestyle', 'coolness', 'tentacles=>8')
db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query)
record = dict(zip((query), (db.fetchall()))
array = '''{
'''
for k,v in record:
array.append('"(k)":"(v)"')
array.append('''
}''')
On Aug 27, 2:37*pm, TYR <a.harrow...@gmail.comwrote:
There's always the naive option.
query = ('species', 'lifestyle', 'coolness', 'tentacles=>8')
db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query)
record = dict(zip((query), (db.fetchall()))
array = '''{
* * * * * * *'''
for k,v in record:
* array.append('"(k)":"(v)"')
array.append('''
* * * * * * * * }''')
Actually, don't.
query = ('species', 'lifestyle', 'coolness')
limit = ('tentacles=>8') This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Igor Prischepoff |
last post by:
Hi,
Is someone have an expierience in distributing
python app with mysqldb module on Win platforms?
I'd like to know, how you packaged and delivered your solution.
Which tool to use, how to...
|
by: sandy |
last post by:
Hi All,
I am a newbie to MySQL and Python. At the first place, I would like to
know what are the general performance issues (if any) of using MySQL
with Python.
By performance, I wanted to...
|
by: ajikoe |
last post by:
Hello I need to build table which need searching data which needs more
power then dictionary or list in python, can anyone help me what kind
of database suitable for python light and easy to learn....
|
by: Aquarius |
last post by:
I appologize in advance for this strange (and possibly stupid)
question.
I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that...
|
by: Cousin Stanley |
last post by:
Greetings ....
I'm using a commercial web host running FreeBSD
that fortunately has Python and MySQL,
but no python-mysqldb module ....
Before begging the host to install it
I thought I...
|
by: Fred |
last post by:
I hope someone can help me with the below problem...
Thanks,
Fred
My enviroment:
--------------------------
Slackware Linux 10.2
Python 2.4.2
MySql version 4.1.14
|
by: jgarber |
last post by:
Hello,
I just upgraded MySQLdb to the 1.2.0 version provided by Redhat
Enterprise Linux ES4. At that point I began to get segfaults when
importing twisted after MySQLdb, but not before.
--...
|
by: Mark Tarver |
last post by:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?
Note I'm not a Python person and I have no axes to grind here. This is
just a question for...
|
by: Gerard M |
last post by:
Hi guys I have a big problem with this wrapper im using Ubuntu 7.04
and I want to install python-MySQLdb, I used synaptics and it is
installed, but when I try to do
and I get this error:
...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |