[sqlalchemy] Re: SA (4.0) mssql table creation problems. No Python Errors?
On Oct 19, 2007, at 8:23 PM, Eddie wrote: > > 2007-10-19 16:26:45,437 INFO sqlalchemy.engine.base.Engine.0x..d0 {} > 2007-10-19 16:26:45,437 INFO sqlalchemy.engine.base.Engine.0x..d0 > COMMIT > the end > (--END--) > yeah this is something configurational with your DBAPI. anything wrong on the python side would throw an exception which you'd see...that the program just ends, something native is going on. try writing a simple DBAPI (no sqlalchemy) program that just imports the driver and issues a connect(). try it also using the *wrong* hostname, so that it fails with a "host not found" error, to make sure it can do that muchit could be just importing the driver thats crashing it, and you might have to make sure things are installed properly (up to date versions of DLLs, etc.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SA (4.0) mssql table creation problems. No Python Errors?
> sounds like something is crashing inside the DBAPI driver. try > taking whatever SQL output is printed and trying it manually. Doesn't even make it that far. I shortened the program even more to this and have the same problem: from sqlalchemy import * connectionString = 'mssql://sa:[EMAIL PROTECTED]:1433/ServerMonitor' #connectionString = 'sqlite:///' engine = create_engine(connectionString, echo=True) meta = MetaData(engine) Services = Table( 'Services', meta, Column('ID', Integer, primary_key=True), Column('Name', String(255)), ) print "test" meta.create_all(engine) print "the end" If I leave the code as is, I get: (--START--) C:\>test.py test 2007-10-19 16:26:45,421 INFO sqlalchemy.engine.base.Engine.0x..d0 PRAGMA table_i nfo("Services") 2007-10-19 16:26:45,421 INFO sqlalchemy.engine.base.Engine.0x..d0 {} 2007-10-19 16:26:45,421 INFO sqlalchemy.engine.base.Engine.0x..d0 CREATE TABLE "Services" ( "ID" INTEGER NOT NULL, "Name" VARCHAR(255), PRIMARY KEY ("ID") ) 2007-10-19 16:26:45,437 INFO sqlalchemy.engine.base.Engine.0x..d0 {} 2007-10-19 16:26:45,437 INFO sqlalchemy.engine.base.Engine.0x..d0 COMMIT the end (--END--) If I comment out the sqlite string, I get: (--START--) C:\>test.py test (--END--) It seems that nobody else is having as trivial a problem as I am... what are some of the common trivial mistakes newbies to db's and python make? I'm beginning to think its something really basic. Shouldn't matter that its running in VM right? :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: vote for Python - PLEASE!
Daniel Haus wrote: > Looks like you're frighteningly successful. You're right, python could > use much more love, but look at this! Obviously the poll is not > representative anymore, is it... Yeah - a little skewed there. On the other hand, the poll wasn't exactly very scientific in the first place. Maybe it'll still trick someone into at least making the python links on the MySQL website actually work. :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Complex objects using sqlalchemy
On Oct 19, 2007, at 6:01 PM, mhearne808[[insert-at-sign-here]]gmail [[insert-dot-here]]com wrote: > > Does anyone have any examples of using more complex classes with > sqlalchemy? I'd like to have a user interface for my objects that > hides as much of the complexity of sqlalchemy as possible. Using the > users/addresses example from the sqlalchemy website (http:// > www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_tables), I'd > like to be able to have a User class that provides a method like: > > getAddresses() > > where this returns a list of (for example) email addresses from the > addresses table, hiding the sqlalchemy syntax from the user. > > However, I can't see how to add a method like this to the existing > users table, since then it would have to know about the users_table > Table object. > > I'm currently working with wrapper classes around the low-level User > and Address objects, but that's getting a little hairy too... > theres no "low-level" User and Address object...those are your classes, and can define whatever behaviors you want. getAddresses() would be a method on the User class which accesses the "addresses" property. theres no direct access to any Table objects required. hope this helps --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SA (4.0) mssql table creation problems. No Python Errors?
On Oct 19, 2007, at 5:52 PM, Eddie wrote: > > Hi guys. Thanks for all the help on my previous topic (MS Access > querying). > > I have another new-userish question about mssql. I wrote some working > code the other day(meaning connection was set up correctly I hope?), > and it doesn't work anymore today. I tried retracing my steps, but I > can't seem to find out what I did to break it. > > I know having people debug for you is really frowned upon (I hate > doing it myself), but I've slowly taken code out of my program until > there's almost nothing left but whats necessary to recreate the > problem. Whats even worse about it is that SA gives NO error messages. > I've reduced the initial point of the problem here: > > from sqlalchemy import * > > class MasterList: > def __init__(self): > self.dbInit("sa", "pass-word", "127.0.0.1") > self.initTables() > > def dbInit(self, user, passwd, location): > connectionString = 'mssql://%s:[EMAIL PROTECTED]:1433/ServerMonitor'% > (user, passwd, location) > self.engine = create_engine(connectionString) > self.meta = MetaData(self.engine) > > def initTables(self): > self.Services = Table( 'Services', self.meta, > Column('ID', Integer, > primary_key=True), > Column('Name', String(255)), > ) > self.meta.create_all(self.engine) > > ml = MasterList() > print "the end" > > > What happens is that it never gets past the create_all statement (no > the end printed when code executed). No error statements are created. sounds like something is crashing inside the DBAPI driver. try taking whatever SQL output is printed and trying it manually. > In the mean time would it be safe to change the connection string to > an sqlite db and then switch back to ms-sql once it starts working > again right? The syntax in SA should be the same for everything > besides the connection string when dealing with table creation, simple > insertion and "simple" querying? yup --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Complex objects using sqlalchemy
Does anyone have any examples of using more complex classes with sqlalchemy? I'd like to have a user interface for my objects that hides as much of the complexity of sqlalchemy as possible. Using the users/addresses example from the sqlalchemy website (http:// www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_tables), I'd like to be able to have a User class that provides a method like: getAddresses() where this returns a list of (for example) email addresses from the addresses table, hiding the sqlalchemy syntax from the user. However, I can't see how to add a method like this to the existing users table, since then it would have to know about the users_table Table object. I'm currently working with wrapper classes around the low-level User and Address objects, but that's getting a little hairy too... Thanks, Mike Hearne --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] SA (4.0) mssql table creation problems. No Python Errors?
Hi guys. Thanks for all the help on my previous topic (MS Access querying). I have another new-userish question about mssql. I wrote some working code the other day(meaning connection was set up correctly I hope?), and it doesn't work anymore today. I tried retracing my steps, but I can't seem to find out what I did to break it. I know having people debug for you is really frowned upon (I hate doing it myself), but I've slowly taken code out of my program until there's almost nothing left but whats necessary to recreate the problem. Whats even worse about it is that SA gives NO error messages. I've reduced the initial point of the problem here: from sqlalchemy import * class MasterList: def __init__(self): self.dbInit("sa", "pass-word", "127.0.0.1") self.initTables() def dbInit(self, user, passwd, location): connectionString = 'mssql://%s:[EMAIL PROTECTED]:1433/ServerMonitor'% (user, passwd, location) self.engine = create_engine(connectionString) self.meta = MetaData(self.engine) def initTables(self): self.Services = Table( 'Services', self.meta, Column('ID', Integer, primary_key=True), Column('Name', String(255)), ) self.meta.create_all(self.engine) ml = MasterList() print "the end" What happens is that it never gets past the create_all statement (no the end printed when code executed). No error statements are created. I do admit that I am using the newest version of SA(4+), which is said to have problems with MSSQL, but I don't think you meant it to be this bad :) Again, any help would be appreciated. In the mean time would it be safe to change the connection string to an sqlite db and then switch back to ms-sql once it starts working again right? The syntax in SA should be the same for everything besides the connection string when dealing with table creation, simple insertion and "simple" querying? Also I have tried using pyodbc to the best of my knowledge (which doesn't go very far in SA)... all i did was add module=pyodbc to the engine string as a parameter and imported it at top. Didn't change the result. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: vote for Python - PLEASE!
Looks like you're frighteningly successful. You're right, python could use much more love, but look at this! Obviously the poll is not representative anymore, is it... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Update statement with join for Mysql
On Oct 18, 2007, at 9:23 AM, Karl Pflästerer wrote: > > Hi, > am I wrong, or is it at the moment not possible to write an update > statement > for Mysql which includes multiple tables like that: > >import sqlalchemy.sql as sql > >query = sql.text("""UPDATE shows AS s INNER JOIN show_artendef > AS sad >ON sad.id = s.art >SET s.seq = s.seq + 1 >WHERE s.seq >= :newseq AND s.seq < :oldseq > AND sad.name = :name""") > > At the moment I use the above but maybe I could write that without > text? > visit_update in mysql.py looks like at the moment I can't use > multiple tables if I'm > not wrong (but I didn't look too deep in the source code). I use SA > 0.4.0 > KP usually I do these as a correlated UPDATE. pretty sure mysql can do these in version 5 UPDATE shows set s.seq = s.seq+1 WHERE s.seq >= :newseq AND s.seq < :oldseq AND EXISTS (select 1 from show_artendef AS sad where sad.name=:name and sad.id=s.art) SA looks like: shows.update(shows.seq.between(x, y) & exists([1], and_(show_artendef.c.name='somename', show_artendef.c.id==shows.c.id)), values={shows.c.seq:shows.c.seq+1}) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Update statement with join for Mysql
Joining tables in an UPDATE statement is not defined in any SQL standard (please correct me if I'm not up to date). MySQL introduced that with some 4.x version. That's why I'd really be surprised to find support of SA for this feature...I'm afraid you are right that this is not possible. But there might be a way to rewrite it using a subquery. (?) Ruben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Connecting to a Microsoft Access Database
Hi, access:///VMCPDB.mdb > > Three slashes! The hostname is empty. And you want the full path to the .mdb file. Paul On 10/18/07, Eddie <[EMAIL PROTECTED]> wrote: > > > Latest Version still gives me problems > > still in the same engine = create_engine('access://VMCPDB') line. > Debug looks like the newest rev installed correctly... > > any help would be nice... > > > [ Things before line 105 are unrelated to SA.. besides the import > lines :) ] > Traceback (most recent call last): > File "monitor.py", line 105, in > engine = create_engine('access://VMCPDB') > File "c:\python25\lib\site-packages\SQLAlchemy-0.4.1dev_r3640- > py2.5.egg\sqlalchemy\engine\__init__ > .py", line 173, in create_engine > return strategy.create(*args, **kwargs) > File "c:\python25\lib\site-packages\SQLAlchemy-0.4.1dev_r3640- > py2.5.egg\sqlalchemy\engine\strategi > es.py", line 67, in create > (cargs, cparams) = dialect.create_connect_args(u) > File "c:\python25\lib\site-packages\SQLAlchemy-0.4.1dev_r3640- > py2.5.egg\sqlalchemy\databases\acces > s.py", line 208, in create_connect_args > connectors.append("Dbq=%s" % opts["database"]) > KeyError: 'database' > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Reflecting Tables does not work with SQLite
On 10/18/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > sqlite doesnt have DECIMAL or TINYINT types defined. sqlite3 > instead as a somewhat bizarre way of indicating types, where you can > use any string you want to indicate a type and it uses search > expressions on the string to determine its storage and column > affinity (the strings that indicate "real numbers" are NUMERIC, FLOA, > REAL, DOUB...no DECIMAL in the list right now). but you can still > put any kind of value in any kind of column. so im not sure if > SQLAlchemy should be making any reflection choices given those > particular names of DECIMAL and TINYINT (i dont think TINYINT is even > part of the SQL standard). You are right about TINYINT not being part of ANSI SQL (http://savage.net.au/SQL/sql-92.bnf.html#exact%20numeric%20type). I know that SQLites has a different approach to the type system, using storage classes and column affinity. However, I think the SQLite backend should at least support the Numeric and DECIMAL datatypes, because *) the backend already supports other datatypes like DATETIME and TIMESTAMP, which are also not native SQLite storage classes *) they are documented at http://www.sqlalchemy.org/docs/04/types.html to exist for the various backends. If TINYINT should be recognized as well, and mapped to SLSmallInteger like SMALLINT already does, remains to be decided. It is probably wrong that SQLObject maps its BoolCol to TINYINT in the SQLite backend. I will talk about this with Oleg Broytman. But maybe this type should also be tolerated and recognized by SQLAlchemy, since "practicality beats purity" ;) One last word about Numeric and DECIMAL: The ANSI standard and MySQL talk about and , whereas SQLAlchemy uses and . Maybe SQLAlchemy should also use "scale" instead of "length" in the code and the documentation. Kind regards, Markus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---