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.