473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

curious paramstyle qmark behavior

With

aColumn = "Topics.Topic1"'

The first statement "works" in the sense that it finds a number of
matching rows.

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE " + aColumn + " LIKE ?", ("%" + sys.argv[1] + "%",))

I've tried about 20 different variations on this next one. And it finds
0 records no matter what I do. Is there some violation when I use two
qmarks?

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE ? LIKE ?", (aColumn, "%" + sys.argv[1] + "%"))

I'm using mx.ODBC and Python 2.4.3 to connect to an MS Access DB.

Thank you,

rd

Oct 20 '06 #1
6 1625

BartlebyScrivener wrote:
With

aColumn = "Topics.Topic1"'

The first statement "works" in the sense that it finds a number of
matching rows.

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE " + aColumn + " LIKE ?", ("%" + sys.argv[1] + "%",))

I've tried about 20 different variations on this next one. And it finds
0 records no matter what I do. Is there some violation when I use two
qmarks?

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE ? LIKE ?", (aColumn, "%" + sys.argv[1] + "%"))

I'm using mx.ODBC and Python 2.4.3 to connect to an MS Access DB.

Thank you,
At a guess; it's probably translating the first '?' (the one after the
WHERE) as a string literal: so your query string is effectively "select
<fieldsfrom <tablewhere 'somestring' like '%<sys.argv[1]>%'".

I would try re-writing it like:
c.execute("select <fcolumnsfrom <tablewhere %s like ?" % aColumn,
"%" + sys.argv[1] + "%")

I don't use mx.ODBC, and definately don't use Access (gagging sounds...
but if you're stuck with it, so be it)...

hth,

Jon.

Oct 20 '06 #2
BartlebyScrivener schrieb:
With

aColumn = "Topics.Topic1"'

The first statement "works" in the sense that it finds a number of
matching rows.

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE " + aColumn + " LIKE ?", ("%" + sys.argv[1] + "%",))

I've tried about 20 different variations on this next one. And it finds
0 records no matter what I do. Is there some violation when I use two
qmarks?

c.execute ("SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM
QUOTES7 WHERE ? LIKE ?", (aColumn, "%" + sys.argv[1] + "%"))

I'm using mx.ODBC and Python 2.4.3 to connect to an MS Access DB.
Parameter passing only works for literal values - not for creating sql
statements.

So, actually your first version is the correct version.

Diez
Oct 20 '06 #3
Thanks, Jon.

I'm moving from Access to MySQL. I can query all I want using Python,
but so far haven't found a nifty set of forms (ala Access) for easying
entering of data into MySQL. My Python is still amateur level and I'm
not ready for Tkinkter or gui programming yet.

rd

----------

Jon Clements wrote:
>
I don't use mx.ODBC, and definately don't use Access (gagging sounds...
but if you're stuck with it, so be it)...

hth,

Jon.
Oct 20 '06 #4

BartlebyScrivener wrote:
Thanks, Jon.

I'm moving from Access to MySQL. I can query all I want using Python,
but so far haven't found a nifty set of forms (ala Access) for easying
entering of data into MySQL. My Python is still amateur level and I'm
not ready for Tkinkter or gui programming yet.
Not wanting to start a RDMS war, I'd personally choose PostgreSQL over
MySQL. (Quite interestingly, most Python programmers go for PostgreSQL
and most PHP programmers go for MySQL)... However, only you know what
you really want to do, so it's up to you to evaluate which RDMS to go
for!

In terms of data entry; if you're able to extend the idea of GUI a
little, why not use web forms? The django project, although I've only
played with it, was quite nice to set up and get running straight away:
if your load on the data-entry/browsing side isn't too heavy, you can
use the 'development server' instead of installing a full-blown server
such as Apache (I'm not sure if IIS is supported).

Users need not have any specific software (well, apart from a web
browser), you can change the back-end any time, have authentication,
the database and users can be remote to the actual "GUI" etc....

Just some thoughts you can do with as you wish.

Jon.

Oct 21 '06 #5

Jon Clements wrote:
However, only you know what
you really want to do, so it's up to you to evaluate which RDMS to go
for!
That assumes a lot :) My needs are simple. I'm exploring. My only real
db is a collection of 5,000 quotations, book passages etc. Flat file
would probably even do it. But I like to learn. Converted to sqlite
with no problem. But I'll try Postgres, just for fun. I guess I was
drawn to MySQL only because it's part of a WordPress site/blog I
operate, and the conversion tools from Access to MySQL were a snap.
In terms of data entry; if you're able to extend the idea of GUI a
little, why not use web forms?
This never occurred to me. Good idea! I'll explore.
if your load on the data-entry/browsing side isn't too heavy, you can
use the 'development server' instead of installing a full-blown server
such as Apache (I'm not sure if IIS is supported).
What's IIS?
Users need not have any specific software (well, apart from a web
browser), you can change the back-end any time, have authentication,
the database and users can be remote to the actual "GUI" etc....

Just some thoughts you can do with as you wish.
Thank you, I shall explore.

Rick

Oct 21 '06 #6

BartlebyScrivener wrote:
Jon Clements wrote:
if your load on the data-entry/browsing side isn't too heavy, you can
use the 'development server' instead of installing a full-blown server
such as Apache (I'm not sure if IIS is supported).

What's IIS?
It's Internet Information Services: the MS web/ftp server, that's
standard on some window platforms (Control Panel->Add/Remove
Software->Add/Remove Windows Components - or something like that). I
assumed you were on Windows because of you mentioning Access.

Good luck with your project Rick.

All the best,

Jon.

Oct 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob Parnes | last post by:
The following script is a one person's comparison of three methods for accessing a postgresql database using psycopg on a debian computer running python2.3. Following it are the results of running...
11
by: Dave Anderson | last post by:
Consider the following: var GUID = Server.CreateObject("Scriptlet.TypeLib").GUID Let's assume GUID is {9A46FCC9-A7A1-4C96-9394-B1A966CEC081}. I happened to notice that if I concatenate this...
0
by: ckhoge | last post by:
Hi, Consider this code fragment, based on the article "Using Chains to Free Library Code" from the July 2005 issue of C/C++ Users Journal: -- begin listing -- template <class T> struct Foo...
8
by: LAvoisieR | last post by:
Following test code behaviour suprised me and I dont know what's wrong with this. I have two overloaded constructors within base class and virtual destructor implemented. Derived class uses...
40
by: Confused User | last post by:
I am curious what the origins of size_t are. I see that it is usually typedef'd to be the native integer size of a particular machine. I also see that routines like strncpy(char *t, const char *s,...
35
by: Stan Milam | last post by:
The following code implements a strcat-like function which can receive a variable number of arguments. I thought it would be faster if I kept a pointer to the end of the string as it is built so...
30
by: questions? | last post by:
say I have a structure which have an array inside. e.g. struct random_struct{ char name; int month; } if the array is not intialized by me, in a sense after I allocated a
15
by: Jim B. Wilson | last post by:
Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints...
2
by: Matthew Franz | last post by:
I'm probably fundamentally misunderstanding the way the interpreter works with regard to scope, but is this the intended behavior... franz-macbook:~ mdfranz$ python unboundlocal.py ('Darwin',...
3
by: Daniel | last post by:
Hello, I'm developing an application that accesses both a MySQL and an SQLite database. I would like to have named parameters in my SQL and have found the following: For MySQL my named...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.