great to here that the tds version hack worked

if you need help with the double db thing please open a new thread, I
supplied a link for a nice tutorial (the one I worked with, with the
project I'm just finishing) in one of my previous posts in this
thread.
also, as I mentioned this isn't bug free. and I had to hack into it
some more in order for it to work

On Dec 19, 3:21 pm, Timuçin Kızılay <[email protected]> wrote:
> The ms sql codepage is windows-1254 (Turkish) and the database collation
> is "Turkish_CI_AS"
>
> after changing the tds version to 10.0, it worked but I had to change
> the bootstrap.py to insert turkish chars to the database properly.
>
> I had to use encode function to see turkish chars on the sql server
> properly.
>
> This is how I use encode:
> ------
> u.display_name = u'Example manager *ĞÜŞİÖÇ*'.encode('WINDOWS-1254')
> -------------
>
> I'm working on an empty test database to see if I can use mssql
> properly. When I start a real project, I'll use main database on
> postgresql with auth.py and others and I'll use the existing mssql
> database just to read some data and some occasional updates.
>
> Now I'm looking for a working example of using two database connections.
>
> I think I need model.DBSession for main database on postgresql and
> model.DBSession2 for mssql database.
> Working with postgresql and using utf8 for all strings is fine and I
> think its ok to use encode function for mssql server data.
>
> On 19-12-2011 15:00, alonn wrote:
>
>
>
>
>
>
>
> > there seems to be an answer here:
> >http://www.saltycrane.com/blog/2011/09/notes-sqlalchemy-w-pyodbc-free...
> > for an almost exact problem, changing the tds_version number seemed to
> > help them. since I connected from a windows machine while you are
> > doing this from a linux machine like the url I provided.
>
> > If this doesn't work think about seperating the tg db (for auth,user
> > etc) from the mssql. and configure tg to use 2 databases.
>
> > I should also check on the created tg_user table what is the column
> > encoding on  the display_name column? what is the table encoding/
> > collation.
>
> > On Dec 19, 12:16 pm, Timuçin Kızılay<[email protected]>  wrote:
> >> here is the summary of my problems with turbogears and mssql server
> >> databases.
>
> >> my odbc.ini in /etc/odbc.ini like this:
> >> [test]
> >> Driver = /usr/lib/odbc/libtdsodbc.so
> >> Description = test
> >> Server = 192.168.0.10
> >> Port = 1433
> >> Database = test
> >> client charset = WINDOWS-1254
> >> TDS_Version = 8.0
>
> >> and my connection string in development.ini :
> >> sqlalchemy.url = mssql+pyodbc://testuser:12345@test
>
> >> when I run paster setup-app command, tha tables created ok but when
> >> running bootstrap.py, if there are any non ascii character I get errors.
>
> >> sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000]
> >> [FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote
> >> procedure call (RPC) protocol stream is incorrect. Parameter 5: The
> >> parameter name is invalid. (8005) (SQLExecDirectW)') 'INSERT INTO
> >> tg_user (user_name, email_address, display_name, password, created)
> >> OUTPUT inserted.user_id VALUES (?, ?, ?, ?, ?)' ('manager',
> >> '[email protected]', 'Example manager
> >> *\xc4\x9e\xc3\x9c\xc5\x9e\xc4\xb0\xc3\x96\xc3\x87*',
> >> '77551410b646190fb691dd78085620e905bbdbbfc4a1cd23c0f76b7b71dd1a0d00cf005b2e
> >>  f164e90ee61b6c9b6b9543a5742a5094e40d4123b6d751d5c122bc',
> >> datetime.datetime(2011, 12, 19, 11, 27, 8, 957996))
>
> >> I've edited bootstrap.py to put some non-asci chars to strings.
>
> >>           u = model.User()
> >>           u.user_name = u'manager'
> >>           u.display_name = u'Example manager *ĞÜŞİÖÇ*'
> >>           u.email_address = u'[email protected]'
> >>           u.password = u'managepass'
>
> >> I think I need to put some charset encodings of the database to
> >> somewhere but I'm at a loss.
>
> >> working with postgresql and utf8 database is ok, but I need to use an
> >> existing mssql database with windows-1254 charset, that's why I'm trying
> >> to solve this on a test database first.
>
> >> -------- Original Message --------
> >> Subject: RE: tg2 and mssql
> >> Date: Mon, 19 Dec 2011 10:24:58 +0200
> >> From: Alon Nisser<[email protected]>
> >> To: Timuçin Kızılay<[email protected]>
>
> >> Hey
> >> Lets take this back to the tg google group so bigger experts than me
> >> could help you
> >> But I don’t think this a codepage problem (maybe this is, I didn’t see
> >> the error log, btw I'm using utf8 in tg and the mssql is another
> >> encoding and having no problem), bootstrap.py problems hints to another
> >> direction
> >> In order to find out the problem please post the error log you are getting
>
> >> So repost this in the tg group with the full error log, and hopefully me
> >> or someone else could help you out
>
> >> -----Original Message-----
> >> From: Timuçin Kızılay [mailto:[email protected]]
> >> Sent: Monday, December 19, 2011 10:03 AM
> >> To: alonn
> >> Subject: Re: tg2 and mssql
>
> >> Hello,
>
> >> I have full administrative access to ms sql server and the user I use
> >> have dbowner role in that database.
> >> creating the tables is not problem.
> >> I have used this connection string:
> >> sqlalchemy.url = mssql+pyodbc://testuser:12345@test
>
> >> and the table creation is ok now. But when I run paster setup-app
> >> command, after table creation, runs bootstrap.py and I'm getting erros
> >> (I think) its because of codepage problems.
>
> >> Can you send me an example odbc.ini file to set the charset correctly?
> >> My sql server is using windows-1254 charset and after finishing testing
> >> with a newly quickstarted project, I need to use an existing production
> >> database that I can not change the charset because it's being used by
> >> another application. I can add extra tables but can not change the
> >> existing tables so I need to use the existing codepage.
>
> >> On 16-12-2011 21:26, alonn wrote:
> >>> 1. I just finished a project with mssql and tg2.1.3. after some
> >>> wrestling works fine with sql alchemy , tg2 etc.
> >>> 2. you should install pyodbc inside the project for this to work 3. do
> >>> you have full write access to the mssql db and in liberty of changing
> >>> it? since tg2 with authorization and autentication needs to build some
> >>> background tables. if (like me) you can already write to specific
> >>> tables in the mssql db but not in liberty of changing it - you'll have
> >>> to configure tg2 with 2 databases. here's a nice post on
> >>> that:http://www.blog.pythonlibrary.org/2009/06/13/using-multiple-
> >>> databases-in-turbogears-2/  also be warned - there are some problems
> >>> not specified here..
> >>> 4. to get the model of the already generated tables in mssql besides
> >>> using reflection and autoload - that from my exprience didn't work as
> >>> expected with mssql (unlike with mysql - where this works fine) -
> >>> instead I used sqlautocode to auto generate the tables in sqlalchemy
> >>> declarative style.
> >>>http://turbogears.org/2.1/docs/main/Utilities/sqlautocode.html
> >>> 5. my sqlalchemy.url connection string didn't involve pydobc just
> >>> mssql:user:blabla etc  maybe this is a problem
>
> >>> good luck!
>
> >>> On 16 דצמבר, 17:18, Timuçin Kızılay<[email protected]>    wrote:
> >>>> On 15-12-2011 14:14, Alessandro Molina wrote:
>
> >>>>> 2011/12/15 Timuçin Kızılay<[email protected]>:
> >>>>>> Hello,
>
> >>>>>> I have to write an application using ms sql server database. I have
> >>>>>> to use an existing database that being used in the company and my
> >>>>>> app should do some data entry and lots of reporting.
>
> >>>>>> I'd like to use turbogears because the other option is to use .net.
>
> >>>>>> I have some questions because I have only used postgresql with
> >>>>>> turbogears before.
>
> >>>>>> -first question is codepage issues. in tg I'll use utf8 and the
> >>>>>> mssql database is not using unicode but using another codepage. I
> >>>>>> think this will give me problems.
>
> >>>>> Using SQLA you can expose all your data using Unicode column, so
> >>>>> your application will just work on unicode objects without caring
> >>>>> too much about their representation on the database side.
>
> >>>>> When you connect to the engine you can specify which encoding that
> >>>>> database will use to represent strings, then on python you will just
> >>>>> get unicode strings.
>
> >>>>>> - second: the database is already created and full of data so is
> >>>>>> there any way to get the table definitions in model files automagicaly?
>
> >>>>> Yes, you can use table reflection.
> >>>>> The quickstarted project already has some commented lines of code
> >>>>> inside the model to guide you at setting it up.
>
> >>>>> You can even use sqlalchemy-migrate to autogenerate the model from
> >>>>> the tables, which gives you a little bit more control over your models.
>
> >>>>>> - third: is there any sample code using mssql databases?
>
> >>>>> If you use SQLAlchemy (which is the default database layer for TG)
> >>>>> any example around should work correctly even on mssql.
>
> >>>> I'm familiar with SQLAlchemy (in fact, SA is a good reason to use
> >>>> tg2) and I have developed apps with tg2 and SA on postgresql but I'm
> >>>> at a loss here to connect to ms sql server
>
> >>>> I think I need a step by step guide to what libraries to install and
> >>>> what connection string in development.ini file.
>
> >>>> I'm getting this error when I run paster setup-app development.ini on
> >>>> a newly quicstarted app to connect mssql database:
>
> >>>> ----------
>
> >>>> sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001]
> >>>> [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0)
> >>>> (SQLDriverConnectW)') None None
> >>>> ----------
>
> >>>> and my connection string in developmenbt.ini is this:
>
> >>>> sqlalchemy.url = mssql+pyodbc://testuser:[email protected]:1433/test
>
> >>>> I'm running TG2 on linux. (xubuntu 11.10 x64)-הסתר טקסט מצוטט-
>
> >>>> -הראה טקסט מצוטט-

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to