MySQLdb syntax issues - HELP
John Machin
sjmachin at lexicon.net
Sun Dec 16 16:22:30 EST 2007
On Dec 17, 7:48 am, Luke <elven... at msn.com> wrote:
> Bruno Desthuilliers wrote:
> > Luke a écrit :
> (snip)
> >> cursor.execute("""
> >> CREATE TABLE %s
> >> (
> >> name CHAR(40),
[snip]
> >> luc TEXT
> >> )
> >> """ % CharAccount)
>
> > Err... Are you sure you want a new table here ?
>
> (snip)
>
> yes, thats the easier way i can think of for now since i am so new to SQL,
> eventually im sure i will put all the characters into one larger table
> though... but for now i just dont feal like figuring out how to scan the
> table for the records i need based on name of character...
Have you figured out how to scan a list of table names for the records
you need? Where will you keep that list -- in another table? in a
file? hard-coded in your scripts?
> ill save that
> for later. (unless there is a very easy way to do it that doesnt require
> re)
>
If you have one table (as you should) called (say) "character", with
the primary key column called (say) "characcount", you can find one
exact match like this:
SELECT * FROM character WHERE characcount = 'Ronin88'
or do a wild-card search like this:
SELECT * FROM character WHERE characcount LIKE 'Ron%'
[I'm presuming that's what you mean by your reference to 're']
HTH,
John
More information about the Python-list
mailing list