[SQLObject] how to get generator number

2007-11-07 Thread Petr Jakeš
Hi, I would like to use IDs generated by generator in my application. I am using Firebird DB. Now I go like: genVal = connection.queryOne(SELECT GEN_ID( GEN_PERSON, 1 ) FROM RDB$DATABASE) or for Firebird 2.0 genVal = connection.queryOne(SELECT NEXT VALUE FOR GEN_PERSON FROM RDB$DATABASE) Is

Re: [SQLObject] how to get generator number

2007-11-07 Thread Petr Jakeš
mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss -- Ing. Petr Jakeš TPC spol. s r.o. Průmyslová 1137 506 01 Jičín Czech republic, Europe www.tpc.cz mobile: +420-777-172450

Re: [SQLObject] how to get generator number

2007-11-07 Thread Petr Jakeš
On Nov 7, 2007 11:53 PM, Oleg Broytmann [EMAIL PROTECTED] wrote: On Wed, Nov 07, 2007 at 11:51:04PM +0100, Petr Jake?? wrote: I just wondered if there is a method within the SQLObject to do this job. There is, but it is rather complex. You have to create your own connection class whose

Re: [SQLObject] how to get generator number

2007-11-08 Thread Petr Jakeš
for showing me (and I hope others in this list as well) which way to go. Petr Jakes Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. -- Ing. Petr Jakeš TPC spol. s r.o. Průmyslová 1137 506 01

[SQLObject] I am confused by the example in FAQ

2007-11-28 Thread Petr Jakeš
Hi, I am trying to follow up the first example in: http://www.sqlobject.org/FAQ.html#how-can-i-do-a-left-join it should return same results as the following SQL select: SELECT customer.id, customer.first_name, customer.last_name, contact.id, contact.address FROM customer LEFT JOIN contact ON

Re: [SQLObject] I am confused by the example in FAQ

2007-11-28 Thread Petr Jakeš
On Nov 28, 2007 11:40 PM, Oleg Broytmann wrote: On Wed, Nov 28, 2007 at 11:34:49PM +0100, Petr Jake?? wrote: But there is not MultipleJoin or RelatedJoin in the given example But there are no descriptions for Customer and Contact tables/classes, and still we dare to call

Re: [SQLObject] I am confused by the example in FAQ

2007-11-28 Thread Petr Jakeš
Finaly I was succesful after some googling. Sorry I did not it before asking my question, but I was confused by the example mentioned in the FAQ. To provide feedback to others it was necessary to add the name of the column where the join is made. class Customer(SQLObject): class sqlmeta:

Re: [SQLObject] I am confused by the example in FAQ

2007-11-28 Thread Petr Jakeš
My hair-pulling continues... How can I add more conditions in to the final SELECT. I mean I am able to get the table objetcs: class Customer(SQLObject): class sqlmeta: fromDatabase = True idName = CUST_NO sales = MultipleJoin('Sales', joinColumn='CUST_NO') class

Re: [SQLObject] refreshing atribute values, how?

2007-12-04 Thread Petr Jakeš
On Tue, Dec 04, 2007 at 10:50:58PM +0100, Petr Jake?? wrote: I would like my atributes have actual values from the database in the time they are used (called). Trying to googling and searching discussion goups for a while, I have found following solution: class sqlmeta:

[SQLObject] export_csv_zip does create compressed file

2007-12-07 Thread Petr Jakeš
Hi, I have found following code does create file myFile.zip which contains 2 csv files (hisSelect.csv, salSelect.csv), but the .zip file size is approximately same as the size of hisSelect.csv + salSelect.csv files. I mean no real compression is done. Thanks for your comments. hisSelect =

Re: [SQLObject] myObject.select() DISTINCT, how?

2007-12-09 Thread Petr Jakeš
On Dec 9, 2007 6:28 PM, Oleg Broytmann wrote: On Sun, Dec 09, 2007 at 12:22:27AM +0100, Petr Jake?? wrote: Is there a way how to force myObject.select() method to return defined columns only? (SELECT first, second, third FROM MY_OBJECT) There is no. Use sqlbuilder.Select() from the trunk

[SQLObject] Insert a row without knowing the names of the columns

2007-12-22 Thread Petr Jakeš
Hi, is there a way how to insert the whole row dataset without knowing the names of the columns? In the SQL it is possible (I mean it is not necessary to specify the names of the columns if the data in the dataset are ordered correspondingly with the columns in the table): This Persons table:

Re: [SQLObject] sqlobject - python question/issue

2007-12-30 Thread Petr Jakeš
could somone perhaps point me to either a code chunk that i can run as a test to see what i'm missing! or could someone point me to additional docs on this.. Hi, Tested on Win XP, Python 2.5.1 8-- #!/usr/bin/env python # -*- coding: cp1250 -*- import os,

Re: [SQLObject] sqlobject - python question/issue

2007-12-30 Thread Petr Jakeš
Sorry for small mistake in my previous posting. You can rem following row in teh code as well. #idName = PO_NUMBER Petr Jakes - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual

Re: [SQLObject] sqlobject - python question/issue

2007-12-30 Thread Petr Jakeš
Forgive me for a basic/simple question. If I already have a mysql db/tbl schema, so I've already created my test mysql db/tbls... How can i simply read the tbl, and then insert a test row/value with a tbl that has an id of a varchar? sample mysql db use test; //test db name create

Re: [SQLObject] sqlobject - _init question....

2007-12-31 Thread Petr Jakeš
1) still do not understand why you using the SQL when you can create/drop tables from Python using SQLobject: MyTable.dropTable(ifExists=True) MyTable.createTable(ifNotExists=True) 2) I can't see the purpose of your code. Can you explain why are you trying to set id that way? I would rather set

Re: [SQLObject] Trying to use HAVING clause

2008-01-24 Thread Petr Jakeš
Thanks for your explanation, now how do I get a connection? :) I'm using TurboGears (for the first time). I guess I need to sign up to a TG mailing list now... Hi, in my case, I am doing following: === snip if os.name == 'posix': db_filename =

[SQLObject] simultaneous conection to 2 different databases

2008-02-05 Thread Petr Jakeš
Hi, I have not clue how to realize simultaneous conection for two different databases in one script. For example: 1) db_filename = '/opt/firebird/examples/empbuild/automat.fdb' connection_string = 'firebird://127.0.0.1:3050/' + db_filename connection = connectionForURI(connection_string)

Re: [SQLObject] simultaneous conection to 2 different databases

2008-02-05 Thread Petr Jakeš
You cannot do this with sqlhub. You have to pass the second connection as the connection parameter to all SQLObject methods: connection2 = connectionForURI('sqlite:///work/mincovnik.db') ATable.select(clause, connection=connection2) Oleg. So you mean it is OK to crate table object

Re: [SQLObject] simultaneous conection to 2 different databases

2008-02-05 Thread Petr Jakeš
Yes. And you don't need to redecalre tables - if MyTable and MyTable2 are realy the same table - just do MyTable.createTable(ifNotExists=True, connection=connection2) And after that, it is not necessary to take care about the connection in the rest of the code? No, after that there

Re: [SQLObject] simultaneous conection to 2 different databases

2008-02-05 Thread Petr Jakeš
On Feb 5, 2008 11:14 PM, Petr Jakeš [EMAIL PROTECTED] wrote: On Feb 5, 2008 11:05 PM, Oleg Broytmann [EMAIL PROTECTED] wrote: On Wed, Feb 06, 2008 at 12:57:08AM +0300, Oleg Broytmann wrote: class MyTable(SQLObject): _connection = connection class MyTable2(SQLObject

[SQLObject] creating an empty Firebird database

2008-02-06 Thread Petr Jakeš
Hi, is there a way how to creat an empty FB database using SQLobject? Petr Jakes - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.

Re: [SQLObject] creating an empty Firebird database

2008-02-06 Thread Petr Jakeš
Currently SQLObject can only create an empty DB on PostgreSQL, and even this has its limitations. Usually one has to have administrative rights to create a new DB, and then delegates rights to connect to the new DB to another user (login/password), so it'd be hard to implement in

Re: [SQLObject] creating an empty Firebird database

2008-02-06 Thread Petr Jakeš
So the code should be (providing that SQLObject's connection knows the user as self.user and self.password): con = kinterbasdb.create_database(create database '%s' user '%s' password '%s' % (self.db, self.user, self.password) It looks promising. But I am not a Firebird guru, so maybe

[SQLObject] store Python objects (function names for example) to the database - is it possible?

2008-02-23 Thread Petr Jakeš
Hi, I know this question is probably silly, but anyway... is it possible to store Python objects (function names for example) to the database? Please understand I do not mean a string containing the name of the function. I would like to store function name to the database and read them and

[SQLObject] select - sum - group by question

2008-03-23 Thread Petr Jakeš
Hi, I have below mentioned table and I really can not figure out, haw to make this select: select coin_type, coin_routing, hodnota_czk, sum(pocet_minci) from coins where coin_routing = 'CASHBOX' group by coin_type, coin_routing, hodnota_czk class Coins(SQLObject): _cacheValue = False

Re: [SQLObject] creating an empty Firebird database

2008-04-09 Thread Petr Jakeš
Oleg, I am still eating, drinking, smoking and inhalling special SQLobject substances from new April release. Because of that I am able to preditct that, thanks to your effort, the SQLObject will be the best db object-relational mapper in the whole Universe in the near future :-) regards Petr

[SQLObject] forceDBName=False

2008-05-07 Thread Petr Jakeš
Hi, trying to connect to the existing Firebird database from the Windows XP machine, I am getting following strange Error: import * from sqlobject.sqlbuilder import * db_filename = 'd|/sgdata/test/sysdat01.gdb' connection_string = 'firebird://172.18.0.10:3050/' + db_filename connection =

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
Yes, there are column names like OID$CENKTGM01, MJ$TYP, AU$VYNOSY, AU$VYNOSY, AU$ZASOBY etc. in the table. The designer of the database is saying such a names are alowed according to the ANSI-92 SQL. SQLObject currently allows only columns that are proper Python identifiers.

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
On Wed, May 7, 2008 at 1:55 PM, Simon Cross [EMAIL PROTECTED] wrote: On Wed, May 7, 2008 at 12:15 PM, Petr Jakeš [EMAIL PROTECTED] wrote: Hi, trying to connect to the existing Firebird database from the Windows XP machine, I am getting following strange Error: C:\Python25\lib\site

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
You can use both at the same time: class MyTable(SQLObject): clas sqlmeta: fromDatabase=True name = StringCol(dbName=a$col) I.e. draw the columns' descriptions from the database but override some of them. I was trying above mentioned on the Win machine still the same

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
Then, it seems, there is no way to make this work with fromDatabase. BTW, SQL-92 doesn't allow '$' in identifiers - it only allows letters, digits and underscore (though most databases extend the rule and allow '$' anyway). :-( The table I would like to connect to has about 130

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
Just declare columns you need and don't use fromDatabase: class MyTable(SQLObject): name = StringCol(dbName=a$name) value = IntCol(dbName=the$value) Yes, I remember I was trying such a syntax at the begening but SQLObject was complaining about ID generator and I was not able to solve

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
No idea what it is. At what time and place SQLObject raises this? The code looks like: class Cenktgm01(SQLObject): _connection = connection nazev = StringCol(dbName=nazev) myTable = Cenktgm01() and the traceback is: C:\automatpython pokusy.py Traceback (most recent call last):

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
Line 98, in _queryInsertID: it tried to execute c.execute('SELECT gen_id(%s,1) FROM rdb$database' % sequenceName) where sequenceName = soInstance.sqlmeta.idSequence or \ 'GEN_%s' % table What is the

Re: [SQLObject] forceDBName=False

2008-05-08 Thread Petr Jakeš
Then you have to generate an ID and pass it to SQLObject: myTable = Cenktgm01(id=ID) Yeah, this works, thanks Petr - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's

[SQLObject] self._connection.queryAll(sql) including headers, how?

2008-06-18 Thread Petr Jakeš
Hi, I am diging data from the Firebird database using quite complex SQL select command. Now I am using self._connection.queryAll(sql) method, but I would like to obtain data including the headers (column names) on the first row as well. Does somebody here know how to force SO to return data and

[SQLObject] timestamp - date select

2008-08-06 Thread Petr Jakeš
Hi, in my tables I am using timestamp field. I would like to select all records from the table that have the same date (not the same timestamp!!), say all records with the date 31.12.2007. What is the best way to do it in the SQLObject? Thanks for your suggestions. Petr Jakes

Re: [SQLObject] timestamp - date select

2008-08-06 Thread Petr Jakeš
from sqlobject import * from sqlobject.sqlbuilder import * __connection__ = sqlite:/:memory:?debug=1 from datetime import datetime class Test(SQLObject): ts = DateTimeCol() Test.createTable() Test(ts=datetime.strptime('2008-08-01 21:44:33', '%Y-%m-%d %H:%M:%S')) print

Re: [SQLObject] Having a modified column filled in automagically...

2008-08-17 Thread Petr Jakeš
I'd like to be able to create a timestamp column called mtime in some of my columns. This would hold a timestamp of when the row was last modified. But I'd like the timestamp to be updated automatically whenever sqlobject updates anything else in the row. How can I do this? I'd like a

[SQLObject] Firebird linux client = windows SQL server problem

2008-10-06 Thread Petr Jakeš
Hi, I have encountered following problem: Firebird db is running on the windows server. the connection string is following: db_filename = 'd|\\sgdata\\test\\sysdat01.gdb' connection_string = 'firebird://winsrv.xxx.xx:3050/' + db_filename connection = connectionForURI(connection_string) From the

Re: [SQLObject] Firebird linux client = windows SQL server problem

2008-10-06 Thread Petr Jakeš
Vertical bar is replaces by a semicolon only on a w32 - it was done specifically for SQLite. I have never considered a possibility for a linux client to connect to a w32 server using w32 filenames. In POSIX OS a vertical bar is a pretty normal character and must not be processed. See:

Re: [SQLObject] Firebird linux client = windows SQL server problem

2008-12-25 Thread Petr Jakeš
Thanks for all users and have a nice end of the year 2008. Petr On Thu, Dec 25, 2008 at 5:22 PM, Oleg Broytmann p...@phd.pp.ru wrote: The explanation is now in the SVN (docs/SQLObject.txt, section 'Firebird' under references). Docs on site will be updated on the next release. Thank you! Sorry

Re: [SQLObject] Traversing a table

2009-01-05 Thread Petr Jakeš
(orderBy = merge_table.q.firstColumn,orderBy = merge_table.q.secondColumn): if actualRow is lastRow: counter+=1 else: if counter: write actual columns + counter+D to the file counter = 0 lastRow=actualRow HTH Petr Jakeš On Mon, Jan 5, 2009 at 11:23

Re: [SQLObject] how to get all records in a table?

2009-01-07 Thread Petr Jakeš
, lname=Doe) Person(fname=Inhahe, lname=Noname) allRows = Person.select() HTH. Petr Jakeš On Wed, Jan 7, 2009 at 6:32 PM, inhahe inh...@gmail.com wrote: hi, can somebody tell me how to select or get all records in a table? i can't seem to find it in the documentation. thanks

Re: [SQLObject] how to get all records in a table?

2009-01-07 Thread Petr Jakeš
On Thu, Jan 8, 2009 at 12:31 AM, inhahe inh...@gmail.com wrote: Oops, I thought I had tried that and that it didn't work (and I didn't see the documentation explicitly mention calling select with no parameters), but it just didn't work due to something I had missed elsewhere. Thanks.

Re: [SQLObject] FW: table ralations

2009-01-08 Thread Petr Jakeš
. Zoran -- *From:* petr.jakes@gmail.com [mailto:petr.jakes@gmail.com] *On Behalf Of *Petr Jakeš *Sent:* Wednesday, January 07, 2009 9:51 AM *To:* Zoran Bošnjak *Cc:* sqlobject-discuss@lists.sourceforge.net *Subject:* Re: [SQLObject] table ralations

Re: [SQLObject] FW: table ralations

2009-01-08 Thread Petr Jakeš
On Thu, Jan 8, 2009 at 3:57 PM, Zoran Bošnjak zoran.bosn...@sloveniacontrol.si wrote: I think, this is the problem of sqlite. Just found it in http://sqlite.org/omitted.html Very first item says: --- FOREIGN KEY constraints are parsed but are not enforced. However, the equivalent

Re: [SQLObject] Use of Foreign Keys and Multiple Join

2009-01-26 Thread Petr Jakeš
from http://exogen.case.edu/turbogears.html : $ tg-admin sql create If you need to change your table definitions, make sure to drop whatever is currently in your database first. To remake your tables, run: $ tg-admin sql drop $ tg-admin sql create I don't know where to put the creation

Re: [SQLObject] Use of Foreign Keys and Multiple Join

2009-01-26 Thread Petr Jakeš
so that tg-admin runs it once but not on every import the model module? Do not really know, but maybe this can help: sql -- wrapper for sqlobject-adminhttp://docs.turbogears.org/1.0/TgAdmin#id4 SQLObject includes a utility called sqlobject-admin. sqlobject-admin includes a number of handy

[SQLObject] foreignkey constraint not set (Firebird)

2009-08-22 Thread Petr Jakeš
Hi, I am trying to follow the Person/Address foreignkey example in the http://www.sqlobject.org/SQLObject.html#foreignkey I am just wondering why the foreignkey constraint is not created on the Address table. The column person_id is created of course, but the foreignkey constraint is NOT set (I

Re: [SQLObject] Illegal names in MySQL

2009-09-13 Thread Petr Jakeš
2009/9/13 Alex xkty...@gmail.com How to use illegal names for MySQL with SQLObject? In pure SQL it is possible to use backuotes, say: SELECT `select from` FROM table1 WHERE 1; ...can be used to select the field called `select from`. My situation is that I already have a DB which I'm trying

[SQLObject] Is there a way to configure kinterbasdb (Firebird)?

2009-09-16 Thread Petr Jakeš
Hi, Working on the Firebird, I just wonder if exists some way how to push SQLObjects to configure kinterbasdb. I mean: I was able to use following snippet when I was working with the database directly (using kinterbasdb). import kinterbasdb kinterbasdb.init(type_conv=200) Is this possible

Re: [SQLObject] Select does not work with some fieldname

2009-11-08 Thread Petr Jakeš
please help. how do i this SQL SELECT * FROM `TAthlet` WHERE TCountry_id = 'AUT' The table TAthlet have this fields: TUnion_id id short name TGender_id TGoup_id TCountry_id This does not work: from sqlobject import * sqlhub.processConnection =

Re: [SQLObject] Select does not work with some fieldname

2009-11-10 Thread Petr Jakeš
2009/11/10 Wolfgang Morawetz wolfgang.moraw...@gmx.at Petr Jakeš schrieb: Maybe you can printout the names SQLObject reads from the database and than use this names: for col in TCountry.sqlmeta.columnList: print col Or maybe: print col.origName, col.dbName

[SQLObject] ForeignKey and MultipleJoin on legacy (existing) database

2010-02-01 Thread Petr Jakeš
Hi, I am trying to connect via SQLObject to the existing database (MySQL - Prestashop database) The database has different naming style than SQLObject expect. I know it is possible to use class sqlmeta: idName = 'id_order' to get primary key working properly. What I really can not

Re: [SQLObject] ForeignKey and MultipleJoin on legacy (existing) database

2010-02-01 Thread Petr Jakeš
I am trying to connect via SQLObject to the existing database You didn't mention fromDatabase but I am sure that what you meant, right? Because it's certainly possible to connect to an existing database without it. What I really can not figure out is how to get ForeignKey and

[SQLObject] how to set dbEncoding for the whole table/database, not for the row?

2010-02-04 Thread Petr Jakeš
Hi, I know below code example works. I would like to know, if it is possible to set the encoding for the whole table at once (or for the connection/database) instead to define it for each column. Petr == code example class Customer(SQLObject): _connection = connection

Re: [SQLObject] how to set dbEncoding for the whole table/database

2010-02-04 Thread Petr Jakeš
There is no currently. What do you want? To define an encoding for all UnicodeCol'umns at once? Yes, that was the main idea. When I am working with existing database, I do not declare columns manually (I am using fromDatabase = True). But I can define encoding for each row manually of

Re: [SQLObject] how to set dbEncoding for the whole table/database

2010-02-05 Thread Petr Jakeš
Well, I added the idea to my TODO. Hmmm... when the connection is set as: connection = connectionForURI(mysql:// prestashop:prestas...@127.0.0.1:3306/prestashop?use_unicode=1charset=utf8) the encoding setting for each column is not necessary.

[SQLObject] how to insert id (primary key) manually to the database?

2010-02-05 Thread Petr Jakeš
Hi, I am working with an existing database (MySQL - Prestashop). On some tables, auto-incrementation for primary key is not used. And I am not able to set it, because it goes against the logic of the application. I know, wired, but... Is it possible to force SQLObject to insert id manually?

[SQLObject] [SOLVED]: how to insert id (primary key) manually to the database?

2010-02-05 Thread Petr Jakeš
Sorry to bother the list. My hands were to fast and my brain to slow (as usually :D ) PsMessageReaded(id = myId, idEmployee=3, dateAdd = tStamp) This code works: PsMessageReaded(idMessage = myId, idEmployee=3, dateAdd = tStamp)

Re: [SQLObject] Manage objects in different databases under the same program instance

2010-02-06 Thread Petr Jakeš
In order to create the DB objects inside the approppriate DB, AFAIK I can pass a connection parameter in the class creation, and all will be fine. But how do I go about doing selects and obtaining results from a specific DB? I may have two DBs open, and each with its file dir structure

Re: [SQLObject] Manage objects in different databases under the same program instance

2010-02-06 Thread Petr Jakeš
I don't think that serves the purpose. The program is supposed to let the user scan whatever structure he/she wants, and this way i'm limiting that, and it is also not scalable. Thanks anyway Than I do not understand your needs. Maybe some simple example or explanation???

[SQLObject] manually created query

2010-02-07 Thread Petr Jakeš
Hi, I have feeling it has been discussed already in the past, but I can not find the answer in the list archive. I would like to query the database something like this: select sum(quantity) as qty, product_name, sum(quantity) * price * (1+tax_rate/100) FROM

Re: [SQLObject] Speed comparison

2010-04-01 Thread Petr Jakeš
Some examples of the code, so we all can learn from your experiences, will be nice. Regards Petr On 1 April 2010 21:30, Juan Manuel Santos vicariou...@gmail.com wrote: I believe I fixed the speed issue. I wrapped the most expensive functions/calls to SQLObject (expensive in terms of I/O) in

Re: [SQLObject] More connections for more tables

2010-04-14 Thread Petr Jakeš
On 14 April 2010 12:11, Oleg Broytman p...@phd.pp.ru wrote: On Tue, Apr 13, 2010 at 11:49:47PM +0200, Visgean Skeloru wrote: Hello is it possible to set a specific connections database for each class? Yes. Every SQLObject class has a classmethod setConnection. Call it

Re: [SQLObject] More connections for more tables

2010-04-14 Thread Petr Jakeš
By the way: How are you solving problem with new creating new database? I mean do you check if the table exist? Because I am using this code: try: alreadyUsed.createTable() Pathject.createTable() print I couldn´t find any table so I h´ve created one! except

[SQLObject] is there a way to (re)set generator?

2010-04-18 Thread Petr Jakeš
Hi, because of the security issues, I am deleting rows in some tables (* destroySelf *method) and I do not want anybody to find, how many rows were inserted in the past in to the table.* *I just wonder if there is a way to (re)set generators to the initial value (1). Best Regards Petr Jakes * *

Re: [SQLObject] is there a way to (re)set generator?

2010-04-19 Thread Petr Jakeš
OMG, you did mean FB generator, not Python! You need to be more specific. (-: Sorry about that, my feeling was all SQL engines are using ID generators to store in it. You need to run your own SQL queries. Something like this: self.query(DROP GENERATOR GEN_%s % soClass.sqlmeta.table)

Re: [SQLObject] select only specified columns

2010-07-01 Thread Petr Jakeš
Creat View in the SQL and than use it in the SQLObject as an ordinary table. You can handle some more complex SQL SELECT within the view. Of course it is read only (I am on Firebird - maybe some other databases behave differently) HTH Petr On 1 July 2010 20:38, Mark markree...@gmail.com

Re: [SQLObject] Altering/updating a database

2011-01-13 Thread Petr Jakeš
It could be as simple as Table.sqlmeta.addColumn(UnicodeCol('name'), changeSchema=True) Yes we are using addColumn method and it works great (Firebird SQL). The other question still remains: How to find if the table was updated already. We are maintaining hundreds of the databases with

Re: [SQLObject] problem with tables

2011-01-19 Thread Petr Jakeš
This sets connection only for the table. And now, when you have the connection to the specific database - call Person.createTable() Oleg, thanks for giving me a lesson. I mean lesson about kindness and helpfulness, not lesson about programming.. Cheers Petr

Re: [SQLObject] DateTimeCol with microsecond resolution.

2011-02-01 Thread Petr Jakeš
I will give this a try, meanwhile I have created my own column type: -- class ISO8601Validator(validators.Validator): def from_python(self, value, state): if value is not None: value = value.strftime('%Y-%m-%d %H:%M:%S.%f') return value def to_python(self,

Re: [SQLObject] Application Design Question

2011-12-11 Thread Petr Jakeš
On 11 December 2011 17:22, Daniel Fetchinson fetchin...@googlemail.comwrote: I need help managing my project files. I've got over 120 class files each that have their own specific validation routines. Most of which are pretty tame, but some are pretty nasty. Anyways, I took a stab at a

Re: [SQLObject] Fwd: Reference to one of multiple tables

2011-12-28 Thread Petr Jakeš
But your example got me thinking. Is something like the following valid? (working example) from sqlobject import * If it is working, then it is (IMHO) valid :D The DB structure is completely up to you of course. But think twice about the DB model. When the production data is in the database

[SQLObject] troubles with unicode

2012-01-29 Thread Petr Jakeš
I am lost, trying to find solution whole night long. all attempts to call the set method (see bellow) are finishing: Page handler: bound method ProdejniMista.ulozeniProdejnihoMista of fantomas.controllers.ProdejniMista instance at 0x2ac67a0 Traceback (most recent call last): File

Re: [SQLObject] troubles with unicode

2012-01-29 Thread Petr Jakeš
The error means there is at least one 8-bit str mixed with unicode. If you are sure all values are str instances - what about dbNames? _SO_update is called from set with dbNames from sqlmeta.columns: args = [(self.sqlmeta.columns[name].dbName, value)

Re: [SQLObject] troubles with unicode

2012-01-29 Thread Petr Jakeš
I thing I am few steps farther but new problem arised: File /TG_web/fantomas/controllers.py, line 305, in ulozeniProdejnihoMista prodMisto.set(**slovnikArgumentu) File /usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/main.py, line 1123, in set

Re: [SQLObject] troubles with unicode

2012-01-31 Thread Petr Jakeš
That's ok. fromDatabase schema guessing in SQLObject is a bit primitive. It works slightly better for The Big Three (MySQL, Postgres, SQLite) but still far from ideal. You have a chance to improve the machinery for Firebird - it is in FirebirdConnection class, methods columnsFromSchema

Re: [SQLObject] troubles with unicode

2012-02-23 Thread Petr Jakeš
On 31 January 2012 18:28, Petr Jakeš petr.ja...@tpc.cz wrote: That's ok. fromDatabase schema guessing in SQLObject is a bit primitive. It works slightly better for The Big Three (MySQL, Postgres, SQLite) but still far from ideal. You have a chance to improve the machinery for Firebird

Re: [SQLObject] troubles with unicode

2012-02-23 Thread Petr Jakeš
After some investigation of the method columnsFromSchema it looks like Firebird (FB 2.5 SuperServer actualy) returns the information about the field type in following form: u'SHORT ' so it is necessary to add t = t.strip() in the for loop (tested) BTW I have found with some luck the FLOAT

Re: [SQLObject] troubles with unicode

2012-02-24 Thread Petr Jakeš
By extending method guessClass. Oleg, I have generated the test tablehttps://docs.google.com/open?id=0B8Qr2m4bDZW0UjJsX0lJVnZScGE5Q2RCbFp4Z1VTQQfor the Firebird 2.5 database. Than using the SQL select I have found on the web, I have queried fields metadata. Details

Re: [SQLObject] troubles with unicode

2012-02-24 Thread Petr Jakeš
After some investigation of the method columnsFromSchema it looks like Firebird (FB 2.5 SuperServer actualy) returns the information about the field type in following form: u'SHORT ' so it is necessary to add t = t.strip() in the for loop (tested) Anyway, I guess it cant hurt anything.

Re: [SQLObject] troubles with unicode

2012-02-25 Thread Petr Jakeš
It seems your DB API adapter (kinterbasedb) returned unicode values. StringCol tried to encode them to strings in dbEncoding (ascii) and failed. Perhaps you have to set a proper dbEncoding. SQLObject 1.1 can set one encoding per table or per connection. Hmmm... the unicode type string comes

Re: [SQLObject] troubles with unicode

2012-02-25 Thread Petr Jakeš
Do you have any idea how to force SQLObject to use the utf-8 instead of ascii for decoding? I think I have found something. I have an other table, where inserting encoded string works. The only difference between these two tables is the field charset definition. Inserting encoded string to

Re: [SQLObject] troubles with unicode

2012-02-26 Thread Petr Jakeš
sqlobject.dburi=firebird://user:password@localhost :3050/pathToTheDatabase/automaty.fdb?charset=utf8 Finally, it looks I was focused on the column values to much, when hunting mentioned UnicodeDecodeError. You can find the solution here: The *names* list generated in: names =

Re: [SQLObject] SqlObject Sqlmeta fromDatabase problem

2012-03-27 Thread Petr Jakeš
fromDatabase: A boolean (default false). If true, then on class creation the database will be queried for the table's columns, and any missing columns (possible all columns) will be added automatically. I started with these class Company(SQLObject): class sqlmeta: fromDatabase =

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
To give context to the issue, I am building my own icecast2 broadcaster. I want to have an Auto DJ feature which will pick a random song from the database which hasn't recently been played plus some other criteria. It really doesn't matter which record i get back from the database, I just

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
Although this might work in the particular application, but it is hardly ideal to make two queries, nor to load a long list of IDs. Is there a way to do it with a single query? 1) Is your task really time critical? How many records (IDs) do you expect to be returned using the first select?

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
Ah. Thanks for the tip. I will look into it; obviously, I would prefer the solution to be engine independent, but this feature might be more valuable :-) As usually, some good search engine (Google??? :D ) is your friend IMHO you have to always know which SQL engine is on the on the

Re: [SQLObject] Vacation

2012-06-04 Thread Petr Jakeš
As usually, beautiful holiday, Oleg :-) Regards Petr On 4 June 2012 12:25, Oleg Broytman p...@phdru.name wrote: I am offline till June 20. Oleg. -- Oleg Broytmanhttp://phdru.name/p...@phdru.name Programmers don't die, they just GOSUB without RETURN.

Re: [SQLObject] ViewSQLObject ID's

2012-06-21 Thread Petr Jakeš
Hi, I am not sure if following is what are you looking for, but in my case, I have a view defined manually on the SQL server side. in the SQLObject I am working with the VIEW like it with an ordinary table, see my code below: === SQLObject part === class HashView(SQLObject):

Re: [SQLObject] ViewSQLObject ID's

2012-06-21 Thread Petr Jakeš
I suppose I was looking for the ViewSQLObject class as a way to achieve the same thing with a lesser need to learn more SQL ... Anyway, thanks for the code example. I reckon I can figure out how it works by reading up on hash joins. Hmmm Views, IMHO, are just SELECTS transformed to

Re: [SQLObject] ViewSQLObject ID's

2012-06-21 Thread Petr Jakeš
Well. I did not understand the syntax of your view definition. In particular, I do not understand the meaning of «hash». Is it a keyword in some dialect of SQL? (I don't find it in postgresql.) If it is a table name, what is then m/m1? Second question, what makes sure that the id,

Re: [SQLObject] ViewSQLObject ID's

2012-06-22 Thread Petr Jakeš
SELECT CAST(t1.id as TEXT) + ':' + CAST(t2.id as TEXT) AS id, ... Just wondering what is delimiter helpful for? Just to recognize t1.id and t2.id later on? Petr -- Live Security Virtual Conference Exclusive live

Re: [SQLObject] Temporary databases / Closing the :memory: database connection

2013-10-17 Thread Petr Jakeš
On 17 October 2013 00:25, Oleg Broytman p...@phdru.name wrote: Not much. I don't know anyone who uses the memory database for any purpose other than testing. Hi, maybe off topic, but I am using in memory database in production environment. The main purpose is to reduce writing to CF card.

Re: [SQLObject] Temporary databases / Closing the :memory: database connection

2013-10-17 Thread Petr Jakeš
On 17 October 2013 17:26, Oleg Broytman p...@phdru.name wrote: Do you close and reopen the memory database in you program(s)? Nope. I am only creating table once at the start of the program: connectionInMemory = connectionForURI('sqlite:/:memory:') class TextyServisnihoDispleje(SQLObject):