[sqlalchemy] Problem on autoload with MS-SQL
With this code I get an error first time I autoload a table: from sqlalchemy import * import pydobc engine = create_engine('mssql://user:[EMAIL PROTECTED]/db', module=pyodbc) meta = BoundMetaData(engine) Table('table_x', meta, autoload=True) # Get error first time Table('table_x', meta, autoload=True) # No error Table('table_y', meta, autoload=True) # Get error first time Table('table_y', meta, autoload=True) # No error Follow traceback for my case: Traceback (most recent call last): File D:\lavoro\aesse periferiche\intermezzo\devel\test.py, line 7, in ? Table('table_x', meta, autoload=True) File c:\python\Lib\site-packages\sqlalchemy\schema.py, line 166, in __call__ metadata.get_engine().reflecttable(table) File c:\python\Lib\site-packages\sqlalchemy\engine\base.py, line 798, in ref lecttable self.dialect.reflecttable(conn, table) File c:\python\Lib\site-packages\sqlalchemy\databases\mssql.py, line 492, in reflecttable coltype = self.ischema_names[type] KeyError: u'timestamp' --~--~-~--~~~---~--~~ 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] Sqlalchemy and py2exe...
Hello, I've tried packing an app I've made with py2exe and run into trouble... first it was an EGG issue, I've fixed that installing everything as a directory next came the sqlite issue... I simply cannot get it to work after I build the .exe I keep getting: Traceback (most recent call last): File patch.py, line 53, in module File model.pyc, line 87, in __init__ File model.pyc, line 56, in createDB File sqlalchemy\schema.pyc, line 1190, in __init__ File sqlalchemy\schema.pyc, line 1095, in __init__ File sqlalchemy\schema.pyc, line 1114, in connect File sqlalchemy\engine\__init__.pyc, line 154, in create_engine File sqlalchemy\engine\strategies.pyc, line 44, in create File sqlalchemy\engine\url.pyc, line 92, in get_dialect ImportError: unknown database 'sqlite' The app works fine when I start it as a script. any idea is welcomed! Thank you in advance. Peter. --~--~-~--~~~---~--~~ 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: checking the sql string.
On May 27, 2007, at 4:23 PM, SamDonaldson wrote: How do I look to see what sql is being constructed in the query object? So if I have something like: q = query.session(User) q = q.add_column() q = q.group_by(.).select() How do I check what sql string has been constructed in q? the Select object is returned by query.compile(). but also you can just enable logging of 'sqlalchemy.engine' or use echo=True on create_engine() which may be more expedient. Also, say I want to do a group by a particular column name on the User table and I have two aggregates, sum, and count? How do I add these two columns to q? Do I just call add_column twice? It's not working, I'm getting an empty result set. q = query.session(User) q = q.add_column(func.sum(User.c.id).label('sum')) q = q.add_column(func.count(User.c.id).label('count')) q = q.group_by([User.c.blah]).select() I'm getting an empty result set. What exactly does label do here? its going to use the AS keyword to apply a column label, such as: select users.id as users_id, users.name as users_name, sum(users.id) as sum, count(users.id) as count FROM users GROUP BY users.blah take a look what its generating and play around with the resulting SQL manually to get an idea about what will return results. --~--~-~--~~~---~--~~ 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: sqlalchemy and running custom sql.
You mean something like this? K --- # Running a SQL Statement using SQLAlchemy from sqlalchemy import * dsn = 'mysql://root:[EMAIL PROTECTED]:3306/tester' # Create a database engine db = create_engine(dsn) # Do some SQL text(INSERT INTO insertable SELECT NULL,txt FROM test_table;, engine=db).execute() On May 27, 1:18 pm, SamDonaldson [EMAIL PROTECTED] wrote: I'd like to be able to run a custom query without having to use any of the ORM stuff. I'd like to pass in a sql query string to some API that returns back to me instances (it'd be great), or tuples. How do I do this? Thanks. --~--~-~--~~~---~--~~ 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] - Very important: Repent, Completely trust in God only and, Love Him with all of your heart. Evolutionism is wrong.
There is a section below with the title Atheism and Evolutionism are WRONG. All those who have sinned deserve to suffer in Hell forever. Pride is an example of a sin. 1. Repent (be truly sorry for your sins; beg for God's forgiveness; abandon sin; ask Him to help you stop sinning; and repent for His sake). 2. Completely trust in God only; do not trust in yourself. 3. Love the Lord with all of your heart. The Son of God (the Lord Jesus Christ) suffered and died on the cross to pay for the sins of those who trust in Him. His blood can clean away our sins. He was buried for three days, then lived again. There is hope of eternal life and happiness for those who trust in God. Your efforts and works cannot save you. Only God is truly righteous and good. Humans are totally corrupt, but thankfully God controls all things. Thank the Lord if He has saved you, and if His Spirit has given you the ability to trust in Him. There is no better God than Him. - Atheism and Evolutionism are wrong: An atheist is a person who does not believe in God. God is the Intelligent Creator of the Universe. If you refuse to trust in God, it's not my loss. 1. Energy/matter cannot be created from nothing nor destroyed (completely annihilated) through natural methods. 2. The Universe cannot create itself. If it created itself, then anything can create itself; and the Universe can have a Mind of its own. 3. Fine-tuning of the Universe: 50 or more parameters/constants have been set by God for the Universe and life to exist. 4. The laws of physics do not order themselves. They have no goals. 5. No oscillating universe; no multiverse. 6. Universe moving towards entropy (or heat death). Therefore, the Universe is not eternal. 7. Planets do not form through natural methods. 8. Gases scatter/dissipate quickly. Therefore, Jupiter have been created. 9. Saturn has three rings. They have been beautifully set in place. 10. Quantized redshifts indicate that the Earth could be near the center of the Universe. This idea is anti-Big-Bang and supports the Bible. 11. The Earth is not millions of years old. Notes: Magnetic field decay; Archaeology; History, other Time limiters. Ancient people were as smart as modern men. Evolutionists have no excuse. DNA cannot exist in natural environments longer than 10,000 years; yet, these have been FOUND in Neanderthal bones, insects in amber, Dinosaur fossils, etc. A dinosaur fossil was discovered still having soft tissue and blood cells. Other keywords: Squashed Polonium-210 halos, Orphan Polonium-218, Helium loss from zircon, Carbon-14 in deep geological strata. 12. Misplaced fossils; Wrong sequence of geological strata/layers; Polystrate fossils are enemies of Uniformitarianism and Evolution. Example: Fish fossils in the Cambrian strata. 13. Decay rates are not constant. Note: Even the speed of light is not constant especially since it can be strongly affected by gravity (such as that of a black hole). As for radiometric dating methods: At least one of them showed that primate skull KNM-ER 1470 was 212-230 million years old. Even evolutionists rejected it. Claystone dating using K-Ar in 1986: 135.2 ± 5.5 Million years old; Dating using Ar-Ar In 1991: 152.9 ± 1.2 Million years old. About 11 million years of decay have occured in just 5 years. Carbon-14 production rate exceeds decay by 30%. Thus, Earth's atmosphere is less than 30,000 years old. 14. NATURAL life can only come from life. Abiogenesis (or spontaneous generation) is impossible. Keywords: Chirality, chemical stability, chemical reactivity, chemical selectivity. 15. The DNA double-helix, self-repair codes, self-checking system/ algorithms, structure, DNA language convention, irreducible cell complexity, and chromosome count are anti-evolution. Also, the DNA molecule stores its information in 3 dimensions, not linearly. 16. DNA of humans differ/vary by about 10-12% from each other. 50% of human DNA is identical to the DNA of a banana. Humans and apes have no common ancestor. 17. Common sense and science reveal the fact of Intelligent Design. There are cells which are more complex than New York City or modern space shuttles. Also read Genesis chapter 3 in the Bible. 18. There is no real vestigial/useless organ. There is no junk DNA. Note: Males' nipples arouse women. The appendix is useful for the immune system. 19. Mutations are harmful, deadly, and destructive to genetic codes. Example: Cancer. 20. Natural selection and Sexual selection seem unable to eliminate destructive genetic codes. Natural Selection is conservative, not innovative. 21. The fossil record and the Cambrian Explosion reveal Creationism and the Global Flood, not evolution. Among all those TRILLIONS of fossils, there were NO mice-bats with one wing or two wings each having 25% bone structure. There were NO walking fishes. 22. The Lord gave humans a conscience, morals, and advanced intelligence. 23. Strong evidence of a Global Flood in the past. This
[sqlalchemy] query.instances and select statement
Hi, I am currently doing the following query: s = select() query = db.query(model.Invoice).options(contains_eager('client')) rs = query.instances(s.execute()) I was wondering if it was possible to instead of query.instances(), just attached the select to the query object, then continue to manipulate the query object further, before executing the query later. eg. s = select() query = db.query(model.Invoice).options(contains_eager('client')) query = query.from_select(s) # query = query.limit(10).offset(10) rs = query.list() What I'm doing, is pretty much setting up a query in one place of my program, then passing this query around, manipulating certain aspects of that query, then finally executing the query in some other place in my program. Thanks Huy --~--~-~--~~~---~--~~ 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] mssql func.cast error?
mssql 2005+sp2 test code --- subject=Table('subject',metadata, Column('subid',Unicode(18),primary_key=True), Column('rest',Float), Column('relevantid',Integer)) print select([func.cast(subject.c.relevantid,'varchar')]).execute().fetchall() general sql -- 'SELECT cast(subject.relevantid, ?)AS cast_9b72 \nFROM subject' cast(subject.relevantid,?) ?? --~--~-~--~~~---~--~~ 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: query.instances and select statement
On May 29, 2007, at 10:28 PM, Huy Do wrote: s = select() query = db.query(model.Invoice).options(contains_eager('client')) query = query.from_select(s) # query = query.limit(10).offset(10) rs = query.list() What I'm doing, is pretty much setting up a query in one place of my program, then passing this query around, manipulating certain aspects of that query, then finally executing the query in some other place in my program. sure you can use query.select_from(myselect). but its not going to modify your select() statement, its giong to apply all those other constraints to a select * from (your select) type of clause. if you want the SQL to be more finely tuned than that youd have to build up your select() separately first. alternatively you can forego making a select() on your own and be totally generative with the query itself, using filter(), order_by(), limit(), 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: mssql func.cast error?
On May 29, 2007, at 11:48 PM, jjx wrote: mssql 2005+sp2 test code --- subject=Table('subject',metadata, Column('subid',Unicode(18),primary_key=True), Column('rest',Float), Column('relevantid',Integer)) print select([func.cast(subject.c.relevantid,'varchar')]).execute ().fetchall() general sql -- 'SELECT cast(subject.relevantid, ?)AS cast_9b72 \nFROM subject' cast(subject.relevantid,?) ?? ? is a bind parameter to which the string value 'varchar' will be applied when executed. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---