Just had a thought;

You could do a few things, unfortunately all at the code base level;

1> I don't know if Python will handle it, but I know most other languages
have a string-replace function, or, more specifically, in Delphi, there is
a "format" command in which you would create a string, fill it in with
parameters (Like %s, %d, etc) and then you have an array of variables the
system would fill in.  Create a variable that contains the SQL you need,
but replace what needs to be quoted with a format specifier.  Then,
regenerate the SQL with either quoted or non-quoted variables.  This would
become a PITA if you had 30 field names or so, however.  Not to mention bug
prone.

2> In line with a true string replace, replace all the field names in the
string to a format like '%db..table%' then run a string replace against all
the possible field names and replace them with either a quoted string, or a
non-quoted string.

3> Another option is to manually mangle the string based on what Sybase is
being fed.  So, if you're going to toss it into SQLite:
- scan the string for double-periods, and remember the position
- backup, character by character, until the first non-valid character, and
put a single/double quote
- go forward+1 from the remembered position until the first non-valid
character, and drop the same quote.

4> The last thing, off the top of my head, would be to locate each and
every SQL string, and move it into a file of its own, then duplicate for
SQLite and mangle as needed.  Along with option 1, nightmare to manage.

My thought, #3 would probably be the easiest to implement, as it'd require
one function to be created and an appropriate result returned then going
through the code and applying the function where needed, but it'd probably
the slowest since you'll be practically touching each and every character
in the string before its fed to the DBMS.  #2 would be next in line as a
search and replace based on field names would PROBABLY be more quicker
instead of mangling strings character by character, but it'd involve going
in and modifying the SQL calls themselves, as well as adding the
appropriate string replace commands.


On Sun, Feb 3, 2013 at 3:50 AM, Message Adams <message.ad...@gmail.com>wrote:

>
> Thanks for everyone's help. Unfortunately, as Ryan highlighted, the double
> quotes around the table 'database..name' cannot be handled by sybase. It's
> a shame as I rather like Sqlite and works soo well with Python.
>
> All the best,
> Marc
>
>
>
>
> On 02/02/13 07:56, Mohit Sindhwani wrote:
>
>> Hi Ryan,
>>
>> On 2/2/2013 1:55 AM, Ryan Johnson wrote:
>>
>>> That would break sybase, though: the quotes would also tell it to treat
>>> the db name and periods as part of the table name, too:
>>>
>>> sqlite3> create table foo(x,y);
>>> sqlite3> .tables
>>> foo
>>> sqlite3> select * from "main.foo";
>>> Error: no such table: main.foo
>>>
>>
>> Since the OP (you aren't the OP, right?)  seems to have control over the
>> code, I wonder if a compile-time macro could be used to attach the quotes
>> around the database name only in the test environment. But, otherwise, I
>> think we're at the end of what can be done with SQLite.
>>
>> Best Regards,
>> Mohit.
>>
>>
>>
>> ______________________________**_________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>>
>
> ______________________________**_________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to