Eliminate "extra" variable

Igor Korot ikorot01 at gmail.com
Sun Dec 15 21:43:53 EST 2013


Hi,

On Sun, Dec 15, 2013 at 4:58 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 15/12/2013 22:46, Igor Korot wrote:
>>
>> Tim,
>>
>> On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase
>> <python.list at tim.thechases.com> wrote:
>>>
>>> On 2013-12-15 06:17, Tim Chase wrote:
>>>>>>>>>
>>>>>>>>> conn = sqlite3.connect('x.sqlite',
>>>>>>
>>>>>> ... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>>>
>>>>
>>>> Your example code omitted this one crucial line.  Do you specify the
>>>> detect_types parameter to connect()?
>>
>>
>> Yes, I did.
>> This is the beginning of the session:
>>
>>>>> import sqlite3
>>>>> conn = sqlite3.connect('c:\Documents and
>>>>> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
>>>>> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>
>>
> When writing paths on Windows, it's a good idea to use raw string
> literals or slashes instead of backslashes:
>
>     conn = sqlite3.connect(r'c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>
> or:
>
>     conn = sqlite3.connect('c:/Documents and
> Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

So, how do I convert my string to one of those?
I realized I can just do replace '/' to '\', but is there a better alternative?

Thank you.


>
>
>> Also please note that you session was missing the cursor creation command.
>> ;-)
>>
>> Thank you.
>>
>>>
>>> It's really the PARSE_DECLTYPES that is important.
>>>
>>> http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES
>>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list