Friday, July 6, 2012

Re: If using South, does it even matter what the underlying database is?

Hi!

I personally find PostgreSQL much easier to work with. (and the docs
are beautiful)

MySQL has ugly docs, weird syntax, and it does unexpected strange
things. (and their terms of use is a little weird I think too.. yes
MySQL has burned me years ago and i've never forgiven it.)

-endofrant-

~Mike
On Sat, Jul 7, 2012 at 12:21 AM, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
> On Sat, 07 Jul 2012 00:34:18 +0100, houmie <houmie@gmail.com> declaimed
> the following in gmane.comp.python.django.user:
>
>> I can't use double quotes in values, e.g.
>>
>> |INSERT INTO app_country (country_code, country_name) VALUES ("AF",
>> "Afghanistan")|
>>
> In standard SQL, double quotes delimit schema entities (table/column
> names), and single quotes delimit strings. MySQL's relaxed parser
> allowed double quotes for strings -- unless...
>
> -=-=-=-
> If the ANSI_QUOTES SQL mode is enabled, string literals can be quoted
> only within single quotation marks because a string quoted within double
> quotation marks is interpreted as an identifier.
> -=-=-=-
>
>>
>> |INSERT INTO app_country (country_code, country_name) VALUES ('AF',
>> 'Afghanistan')
>> |
>>
>> |This however gives me now a big headache with
>> |
>>
>> |Cote D'ivoire
>>
>> The quote there breaks the string in my INSERT statement.
>>
>> Any idea how to solve this?
>>
> Don't hand-code the SQL yourself -- use the DB-API adapter (since
> you state SQL problem you are bypassing the Django ORM system) with
> parameterized queries and let IT handle any escaping needed for such
> characters.
>
> SQL = "insert into app_country (country_code, coutnry_name) values
> (?, ?)"
> {You'll need to check your adapter for the correct placeholder: SQLite3
> uses ?, MySQL uses %s, PostgreSQL use <what>}
>
> Then supply the values as a tuple to the execute command.
> cursor.execute(SQL, ("cd", "Cote D'ivoire") )
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate