Predrag Peranovic wrote:
> Hi,
>
> I'm trying to use Python + SQLObject to develop some simple DB
> application for my use.
>
> I'm pretty new in python and in the SQLObject and think that this is
> trivial question but I don't know how to solve it. So please help.
>
>
> 1. How to get columns name, format , size and rest of attributes
> (like text size, notNull) from an SQLObject?
>
> In version 0.5.2 I use:
> s = SomeSQLObject.select()[0]
> columnName = s._columns[0].kw['name']
> how can I do something like this in 210 version from svn (is this some
> regular way to get that information)
Right now SomeSQLObject._SO_columnDict will give you the Col objects
(keyed by attribute name). In the future, I hope to change all the
columns to be descriptors, so when you do SomeSQLObject.columnName you
will get the Col object, and it will have a clear interface for
introspection. But until then you'll have to track changes, as there's
no stable interface for this yet.
> 2. How to set additional parameters to Firebird connection, like:
> charset, role, dialect?
I've applied these changes to the repository.
Generally, you can still get to the connection via
sqlobject.firebird.FirebirdConnection. Maybe there should be an easier
way. You can also use the URI form.
Any query parameters you use will be passed through as keyword
arguments, though right now only as strings. At some point we might
need to do some translation to different types. Hmm... is dialect
always an integer?
Anyway, you should be able to do
firebird://user:password@host/dbname?charset=ISO-8859&role=admin (or
however those are supposed to be formatted).
> In 0.5.2, I modified methods:
> ------------------------------------------------------------------
> class FirebirdConnection(DBAPI):
> def __init__(self, host, db, user='sysdba',
> passwd='masterkey', autoCommit=1,
> + #insert by me
> + role=None, charset=None, dialect=0,
> + #end of insert
> **kw):
> ...
> + #insert by me to support additional option of firebird database
> + self.dialect = dialect
> + self.charset = charset
> + self.role = role
> + #end of insert
>
> def makeConnection(self):
> #Modified by me to add support for charset, role and dialect
> return kinterbasdb.connect(
> host = self.host, database = self.db,
> user = self.user, password = self.passwd,
> + role = self.role, charset = self.charset,
> + dialect = self.dialect
> )
> ------------------------------------------------------------------
> end get what I need. But now it's look that FirebirdConnection method is
> deprecated.
> Do you have plans to insert this connection options in some future
> release, and how do you think to do that?
> And how do you suggest to modify 210 version from svn to get features
> that I need.
>
> I'm just want to know that to be easy to me to migrate on new version of
> SQLObject.
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|