sqlobject-discuss Mailing List for SQLObject (Page 14)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Oleg B. <ph...@ph...> - 2013-10-17 16:29:03
|
On Thu, Oct 17, 2013 at 06:24:02PM +0200, Petr Jake?? <pet...@tp...> wrote: > On 17 October 2013 17:26, Oleg Broytman <ph...@ph...> 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: I see. Thank you! Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2013-10-17 16:24:10
|
On 17 October 2013 17:26, Oleg Broytman <ph...@ph...> 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): _connection = connectionInMemory level=StringCol(length=1, default=None) text=UnicodeCol(length=20, default=None) cislovatRadek=EnumCol(enumValues=('Y','N'), default='Y') akce=StringCol(length=100, default=None) predek=ForeignKey("TextyServisnihoDispleje", default=None) potomci=MultipleJoin("TextyServisnihoDispleje", joinColumn="predek_id") TextyServisnihoDispleje.createTable() |
From: Oleg B. <ph...@ph...> - 2013-10-17 15:27:03
|
On Thu, Oct 17, 2013 at 05:20:57PM +0200, Petr Jake?? <pet...@tp...> wrote: > On 17 October 2013 00:25, Oleg Broytman <ph...@ph...> 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. Do you close and reopen the memory database in you program(s)? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2013-10-17 15:21:05
|
On 17 October 2013 00:25, Oleg Broytman <ph...@ph...> 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. Petr |
From: Oleg B. <ph...@ph...> - 2013-10-16 22:25:52
|
On Wed, Oct 16, 2013 at 10:58:24PM +0100, "Maciej (Matchek) Blizi??ski" <ma...@op...> wrote: > 2013/10/16 Oleg Broytman <ph...@ph...> > > > It does what I need, but it doesn't seem like it's what SQLObject > > > developers intended. Do you have any recommendations? > > > > I don't. Do you want to propose an API? Or better a patch? > > Hey, thanks for the reply. I'm looking at the code right now, I need > to look more carefully at the current structure before I can suggest > an API or a patch. In general, I can see 4 possibilities: > > - when creating a connection, add an option to not cache that connection That would be easy, just one additional parameter in connectionForURI: cache=True (or useCache or something like that). The approach could lead to problems, though. Every SQLObject's connection maintain its own cache of retrieved rows, so different connections for the same URI will have different caches, so the same row could appear in a few caches; that would lead to unsynchronized read/write operations. > - add an option to clear / expire all the connections in the current cache What gives? Usually if there are a few connections with different URIs the user needs all of them. > - add an option to the close() method so it causes the connection (and > the URI) to expire from the cache Not sure it could be implemented reliably. Connection doesn't know its own DB URI, and reconstructing it could give an equivalent but different URI. > - there already is special handling for in-memory databases, so > maybe add a little more special handling for them; for example free > the memory on close(). That's a good approach; requires testing. > This could potentially break existing > applications, does SQLObject make any guarantees about in-memory > databases? Not much. I don't know anyone who uses the memory database for any purpose other than testing. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Maciej (M. B. <ma...@op...> - 2013-10-16 21:59:12
|
2013/10/16 Oleg Broytman <ph...@ph...> > > It does what I need, but it doesn't seem like it's what SQLObject > > developers intended. Do you have any recommendations? > > I don't. Do you want to propose an API? Or better a patch? Hey, thanks for the reply. I'm looking at the code right now, I need to look more carefully at the current structure before I can suggest an API or a patch. In general, I can see 4 possibilities: - when creating a connection, add an option to not cache that connection - add an option to clear / expire all the connections in the current cache - add an option to the close() method so it causes the connection (and the URI) to expire from the cache - there already is special handling for in-memory databases, so maybe add a little more special handling for them; for example free the memory on close(). This could potentially break existing applications, does SQLObject make any guarantees about in-memory databases? Maciej |
From: Oleg B. <ph...@ph...> - 2013-10-16 13:19:36
|
Hi! On Wed, Oct 16, 2013 at 09:41:54AM +0100, "Maciej (Matchek) Blizi??ski" <ma...@op...> wrote: > Hi guys, > > I'd like to use an in-memory sqlite database for testing, and I have a > problem where I don't seem to be able to let go of a database which was > once created. Here's a test that shows what I mean: > > class Foo(sqlobject.SQLObject): > bar = sqlobject.UnicodeCol(length=250, unique=True) > > db_uri = 'sqlite:/:memory:' > conn = sqlobject.connectionForURI(db_uri) > sqlobject.sqlhub.processConnection = conn > Foo.createTable() > # All is good so far. Now let's drop the database. > conn.close() > del conn > # From http://www.sqlite.org/inmemorydb.html: > # "The database is automatically deleted and memory is reclaimed when the > last connection to the database closes." > # Let's create a fresh in-memory database. > conn = sqlobject.connectionForURI(db_uri) > sqlobject.sqlhub.processConnection = conn > Foo.createTable() > # Here, an exception is thrown: > sqlobject.dberrors.OperationalError: table foo already exists > > I must have somehow gotten a connection to the same in-memory database that > was created on the first call to connectionForURI(). After looking at Yes. Actually, even worse than that - connectionForURI caches SQLObject's connections by URIs (you get the same SQLObject's connection with the same URI) and SQLiteConnection caches a DBAPI connection to the in-memory DB. > dbconnection.py, I came up with an invasive method: > > sqlobject.dbconnection.TheURIOpener.cachedURIs = {} > conn = sqlobject.connectionForURI(db_uri) > sqlobject.sqlhub.processConnection = conn > Foo.createTable() > > It does what I need, but it doesn't seem like it's what SQLObject > developers intended. Do you have any recommendations? I don't. Do you want to propose an API? Or better a patch? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Maciej (M. B. <ma...@op...> - 2013-10-16 08:42:42
|
Hi guys, I'd like to use an in-memory sqlite database for testing, and I have a problem where I don't seem to be able to let go of a database which was once created. Here's a test that shows what I mean: class Foo(sqlobject.SQLObject): bar = sqlobject.UnicodeCol(length=250, unique=True) db_uri = 'sqlite:/:memory:' conn = sqlobject.connectionForURI(db_uri) sqlobject.sqlhub.processConnection = conn Foo.createTable() # All is good so far. Now let's drop the database. conn.close() del conn # From http://www.sqlite.org/inmemorydb.html: # "The database is automatically deleted and memory is reclaimed when the last connection to the database closes." # Let's create a fresh in-memory database. conn = sqlobject.connectionForURI(db_uri) sqlobject.sqlhub.processConnection = conn Foo.createTable() # Here, an exception is thrown: sqlobject.dberrors.OperationalError: table foo already exists I must have somehow gotten a connection to the same in-memory database that was created on the first call to connectionForURI(). After looking at dbconnection.py, I came up with an invasive method: sqlobject.dbconnection.TheURIOpener.cachedURIs = {} conn = sqlobject.connectionForURI(db_uri) sqlobject.sqlhub.processConnection = conn Foo.createTable() It does what I need, but it doesn't seem like it's what SQLObject developers intended. Do you have any recommendations? Maciej |
From: Francisco C. <fra...@gm...> - 2013-10-10 17:17:24
|
Thank you for your help, I am going to ask psycopg team about the problem. If I have some news about how to fix it, i will tell you. Cheers. 2013/9/30 Oleg Broytman <ph...@ph...> > On Sat, Sep 28, 2013 at 01:22:26PM +0400, Oleg Broytman <ph...@ph...> > wrote: > > I returned from the vacation. Will test if psycopg w/o SQLObject > > returns the code/error. > > The following program: > > from decimal import Decimal > import psycopg2 > > def report_error(e): > print e.__class__.__name__, e.pgcode, e.pgerror > raise SystemExit > > try: > con = psycopg2.connect(database="test") > except psycopg2.Error, e: > report_error(e) > > cur = con.cursor() > > try: > cur.execute('SELECT * FROM test ORDER BY id') > except psycopg2.Error, e: > report_error(e) > > prints > > OperationalError None None > > when it cannot connect to the database and prints > > ProgrammingError 42P01 ERROR: relation "test" does not exist > > when the database exists but there is no table "test". I.e., psycopg2 > doesn't return proper code/message for an OperationalError, so your > original request cannot be fullfilled, alas. You can ask psycopg2 > authors if they are going to fix that. > > I will do more tests and include the code into the next release. I > hope to release SQLObject 1.5 RSN. > > Oleg. > -- > Oleg Broytman http://phdru.name/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2013-10-05 12:56:22
|
Hello! I'm pleased to announce version 1.5.0, the first stable release of branch 1.5 of SQLObject. What's new in SQLObject ======================= Features & Interface -------------------- * Helpers for class Outer were changed to lookup columns in table's declarations. * Support for Python 2.4 is declared obsolete and will be removed in the next release. Minor features -------------- * When a PostgresConnection raises an exception the instance has code/error attributes copied from psycopg2's pgcode/pgerror attributes. * Encode unicode enum values to str. * Removed setDeprecationLevel from the list of public functions. * A number of fixes for tests. Bugfixes -------- * A bug was fixed in DBConnection.close(); close() doesn't raise an UnboundLocalError if connection pool is empty. * Fixed parameters for pymssql. Documentation ------------- * GNU LGPL text was added as docs/LICENSE file. * Old FSF address was changed to the new one. Contributors for this release are Patrick Gendron, Rhubarb Sin, Neil Muller, Robert Ayrapetyan, Gert Burger and Francisco Chiotta. For a more complete list, please see the news: http://sqlobject.org/News.html What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: https://pypi.python.org/pypi/SQLObject/1.5.0 News and changes: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2013-09-30 13:52:06
|
On Sat, Sep 28, 2013 at 01:22:26PM +0400, Oleg Broytman <ph...@ph...> wrote: > I returned from the vacation. Will test if psycopg w/o SQLObject > returns the code/error. The following program: from decimal import Decimal import psycopg2 def report_error(e): print e.__class__.__name__, e.pgcode, e.pgerror raise SystemExit try: con = psycopg2.connect(database="test") except psycopg2.Error, e: report_error(e) cur = con.cursor() try: cur.execute('SELECT * FROM test ORDER BY id') except psycopg2.Error, e: report_error(e) prints OperationalError None None when it cannot connect to the database and prints ProgrammingError 42P01 ERROR: relation "test" does not exist when the database exists but there is no table "test". I.e., psycopg2 doesn't return proper code/message for an OperationalError, so your original request cannot be fullfilled, alas. You can ask psycopg2 authors if they are going to fix that. I will do more tests and include the code into the next release. I hope to release SQLObject 1.5 RSN. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2013-09-28 09:22:48
|
Hi! On Thu, Sep 26, 2013 at 11:52:08AM -0300, Francisco Chiotta <fra...@gm...> wrote: > It doesn't work for me either. I have installed the psycopg 2.5.1 (the > latest), and I always get None if the authentication fails or the server is > not working in the given IP. I don't know why. > > 2013/9/15 Oleg Broytman <ph...@ph...> > > > On Fri, Sep 13, 2013 at 11:40:09AM -0300, Francisco Chiotta < > > fra...@gm...> wrote: > > > It would be great. Sure, I can test the results. > > > > The patch is attached. The code and error string are available: > > > > try: > > do_something() > > except OperationalError, e: > > print e.args[0].code > > print e.args[0].error > > > > Doesn't work for me, though -- pgcode/pgerror are always None. > > Perhaps I'm using old version of psycopg2 -- 2.4.5. I returned from the vacation. Will test if psycopg w/o SQLObject returns the code/error. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Francisco C. <fra...@gm...> - 2013-09-26 14:52:19
|
It doesn't work for me either. I have installed the psycopg 2.5.1 (the latest), and I always get None if the authentication fails or the server is not working in the given IP. I don't know why. 2013/9/15 Oleg Broytman <ph...@ph...> > On Fri, Sep 13, 2013 at 11:40:09AM -0300, Francisco Chiotta < > fra...@gm...> wrote: > > It would be great. Sure, I can test the results. > > The patch is attached. The code and error string are available: > > try: > do_something() > except OperationalError, e: > print e.args[0].code > print e.args[0].error > > Doesn't work for me, though -- pgcode/pgerror are always None. > Perhaps I'm using old version of psycopg2 -- 2.4.5. > > Oleg. > -- > Oleg Broytman http://phdru.name/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |
From: Oleg B. <ph...@ph...> - 2013-09-17 19:46:13
|
Ten days vacation. Perhaps I'll be online from time to time... Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2013-09-17 19:05:50
|
Hi! On Tue, Sep 17, 2013 at 08:19:13PM +0200, to...@ce... wrote: > To work with foo = RelatedJoin('Song') we use .foo, .addSong and .removeSong. But those names are configurable. How do I get them when all I know is "foo"? > > One way seems to be sqlmeta.joins[0].performJoin, .add and .remove. Is that an internal API, and subject to change? I have less and less time to work on SQLObject so until someone replaces me as the developer there will be no major changes for quite some time. > How do I get the list index? By looking up the join object you're interested in: class Test1(SQLObject): test2 = RelatedJoin('Test2') class Test2(SQLObject): test1 = RelatedJoin('Test1') for j in Test2.sqlmeta.joins: print j.joinMethodName, j.otherClassName, j.addRemoveName Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <to...@ce...> - 2013-09-17 18:37:03
|
To work with foo = RelatedJoin('Song') we use .foo, .addSong and .removeSong. But those names are configurable. How do I get them when all I know is "foo"? One way seems to be sqlmeta.joins[0].performJoin, .add and .remove. Is that an internal API, and subject to change? How do I get the list index? |
From: Oleg B. <ph...@ph...> - 2013-09-15 13:52:35
|
On Fri, Sep 13, 2013 at 11:40:09AM -0300, Francisco Chiotta <fra...@gm...> wrote: > It would be great. Sure, I can test the results. The patch is attached. The code and error string are available: try: do_something() except OperationalError, e: print e.args[0].code print e.args[0].error Doesn't work for me, though -- pgcode/pgerror are always None. Perhaps I'm using old version of psycopg2 -- 2.4.5. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2013-09-13 17:46:55
|
Hi! On Fri, Sep 13, 2013 at 07:17:35PM +0200, JM Germeshuysen <j.g...@gm...> wrote: > Does anybody know if there are any support for the new FDB driver in > SQLObject, as far as I can tell it only supports the outdated kinterbasedb. The code that you see is the only code. There is no magic, no hidden code. If you see only kinterbasedb -- that's all what's supported. But you can send a patch to extend SQLObject. Do you want to help? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: JM G. <j.g...@gm...> - 2013-09-13 17:17:32
|
Hi, Does anybody know if there are any support for the new FDB driver in SQLObject, as far as I can tell it only supports the outdated kinterbasedb. TIA |
From: Oleg B. <ph...@ph...> - 2013-09-13 15:00:51
|
On Fri, Sep 13, 2013 at 11:40:09AM -0300, Francisco Chiotta <fra...@gm...> wrote: > It would be great. Sure, I can test the results. > > 2013/9/12 Oleg Broytman <ph...@ph...> > > Do you want me to provide e.code for psycopg2? I'll ask you to test > > the result. I will try to do that before taking a vacation next week. If not -- I'll be back at the 28th of September. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Francisco C. <fra...@gm...> - 2013-09-13 14:40:17
|
It would be great. Sure, I can test the results. Cheers 2013/9/12 Oleg Broytman <ph...@ph...> > On Thu, Sep 12, 2013 at 04:43:09PM -0300, Francisco Chiotta < > fra...@gm...> wrote: > > Ok, I thought that It was possible to recover an error code or something > > like that. > > psycopg2 provides some information: > http://initd.org/psycopg/docs/module.html#exceptions > http://initd.org/psycopg/docs/errorcodes.html#module-psycopg2.errorcodes > but SQLObject loose that information when it converts psycopg2's > exceptions to SQLObject's exceptions. I can try to extract that > information but only for SQLObject 1.5 (which is currently in > pre-release state) and only for Postgres/psycopg2 (PySQLite doesn't > return error codes, only strings; exceptions from MySQL already provide > error code in e.code attribute). > Do you want me to provide e.code for psycopg2? I'll ask you to test > the result. > > Oleg. > -- > Oleg Broytman http://phdru.name/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > How ServiceNow helps IT people transform IT departments: > 1. Consolidate legacy IT systems to a single system of record for IT > 2. Standardize and globalize service processes across IT > 3. Implement zero-touch automation to replace manual, redundant tasks > http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2013-09-12 20:12:47
|
On Thu, Sep 12, 2013 at 04:43:09PM -0300, Francisco Chiotta <fra...@gm...> wrote: > Ok, I thought that It was possible to recover an error code or something > like that. psycopg2 provides some information: http://initd.org/psycopg/docs/module.html#exceptions http://initd.org/psycopg/docs/errorcodes.html#module-psycopg2.errorcodes but SQLObject loose that information when it converts psycopg2's exceptions to SQLObject's exceptions. I can try to extract that information but only for SQLObject 1.5 (which is currently in pre-release state) and only for Postgres/psycopg2 (PySQLite doesn't return error codes, only strings; exceptions from MySQL already provide error code in e.code attribute). Do you want me to provide e.code for psycopg2? I'll ask you to test the result. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Francisco C. <fra...@gm...> - 2013-09-12 19:43:19
|
Ok, I thought that It was possible to recover an error code or something like that. Thank you for your help. 2013/9/12 Oleg Broytman <ph...@ph...> > On Thu, Sep 12, 2013 at 03:33:36PM -0300, Francisco Chiotta < > fra...@gm...> wrote: > > Thank you, but I need to distinguish the errors in the except statement, > > something like that: > > > > try: > > connection = connectionForURI('postgres://'+user+':'+password+'@ > > '+host+'/'+database?debug=True) > > sqlhub.processConnection = connection > > connection.query("SELECT 1") > > except OperationalError, e: > > if (user or password are incorrect): > > show a message > > elif (the server is not working): > > to do another thing > > ... > > > > How can I ask the OperationalError object 'e' to do that? > > I don't think database drivers provide such information. You can try > to parse the error message, but they are very database- and > locale-dependent. > > Oleg. > -- > Oleg Broytman http://phdru.name/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > How ServiceNow helps IT people transform IT departments: > 1. Consolidate legacy IT systems to a single system of record for IT > 2. Standardize and globalize service processes across IT > 3. Implement zero-touch automation to replace manual, redundant tasks > http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2013-09-12 18:56:21
|
On Thu, Sep 12, 2013 at 03:33:36PM -0300, Francisco Chiotta <fra...@gm...> wrote: > Thank you, but I need to distinguish the errors in the except statement, > something like that: > > try: > connection = connectionForURI('postgres://'+user+':'+password+'@ > '+host+'/'+database?debug=True) > sqlhub.processConnection = connection > connection.query("SELECT 1") > except OperationalError, e: > if (user or password are incorrect): > show a message > elif (the server is not working): > to do another thing > ... > > How can I ask the OperationalError object 'e' to do that? I don't think database drivers provide such information. You can try to parse the error message, but they are very database- and locale-dependent. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Francisco C. <fra...@gm...> - 2013-09-12 18:33:45
|
Thank you, but I need to distinguish the errors in the except statement, something like that: try: connection = connectionForURI('postgres://'+user+':'+password+'@ '+host+'/'+database?debug=True) sqlhub.processConnection = connection connection.query("SELECT 1") except OperationalError, e: if (user or password are incorrect): show a message elif (the server is not working): to do another thing ... How can I ask the OperationalError object 'e' to do that? 2013/9/12 Daniel Monteiro Basso <dan...@gm...> > Add ?*debug*=True to the connection URL. Also, instead of adding strings, > consider formatting one, such as: > connection = connectionForURI('postgres://{user}:{password}@ > {host}/{database}?*debug*=True'.format(locals())) > > Cheers, > > Daniel > > > On Thu, Sep 12, 2013 at 6:07 PM, Francisco Chiotta <fra...@gm...>wrote: > >> Hello, >> I have a question related with the connections. I am using the >> following code for that: >> >> try: >> connection = connectionForURI('postgres://'+user+':'+password+'@ >> '+host+'/'+database) >> sqlhub.processConnection = connection >> connection.query("SELECT 1") >> except OperationalError: >> print "error" >> >> but, I don't know if the error is because the user and password are wrong >> or the sever is not working. How can I verify that? for example, maybe, >> with a error code but I don't know how to get it. >> >> Cheers, >> >> >> >> ------------------------------------------------------------------------------ >> How ServiceNow helps IT people transform IT departments: >> 1. Consolidate legacy IT systems to a single system of record for IT >> 2. Standardize and globalize service processes across IT >> 3. Implement zero-touch automation to replace manual, redundant tasks >> >> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss >> >> > |