To connect to BBDD (Oracle) through Python, I use the sqlalchemy library.
With the connection.execute(query) command I get the data without problems but I am not able to get the description that each field has.
For example, for the variable called ID_Customer=1111 and it has as description: it is the customer identifier.
How can I get that description?
Thanks!
Related
I need to write a python program to create a table and add columns to it but the name and the quantity of tables and its columns will we user defined means I don't know the name and quantity, it will all be taken as an input from user.
any idea how to do it?
I think using the sqllite3 package it is possible. All you need to do is run the queries with a connection to your database.
I'm trying to execute this query, it's working fine in MySQL workbench, but It's not working in python shell.
And I have to export that result in an Excel sheet.
As de error suggests the SELECT clause must contain the primary key in order to be able to build the ORM object. By default, the primary key is a column named pk. I advise using "SELECT *" in this case if possible, maybe the "AS" could give problems too.
I want to fetch a document from a collection i.e Company which contains a certain field i.e Name.
I have tried the following query but it does not work. Can somebody help me in correcting this query or maybe suggest a different query to get what I need? Thanks
Company.objects.get(name__isnull=False)
You can use exists operator
Python.objects(name__exists=True)
I am using pythons simple-salesforce to fetch information from sf. My requirement is to pul data about cases in queues set up by my organisation. I am unable to gather information from queues,cause I don’t know how to access them using SOQL,is there any online resource that might help me get there?
You can query queues from the Group object.
Select Id from Group where Type = 'Queue'
For a specific queue you can use:
Select Id from Group where Type = 'Queue' AND NAME = 'QueueName'
You can find all available fields for the Group object here: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_group.htm
You should check out workbench.developerforce.com which lets you write SOQL queries and run them against SF objects.
So write your query there first, then replicate in Python
I'm pretty new to database and server related tasks. I currently have two tables stored in a MSsql database on a server and I'm trying to use python package sqlalchemy to pull some of the data to my local machine. The first table has default schema dbo, and I was able to use the Connect String
'mssql+pyodbc://<username>:<password>#<dsnname>'
to inspect the table, but the other table has a customized schema, and I don't see any information about the table when I use the previous commands. I assume it is because now the second table has different schema and the python package can't find it anymore.
I was looking at automap hoping the package offers a way to deal with customized schema, but many concepts described in there I don't quite understand and I'm not trying to alter the database just pulling data so not sure if it's the right way, any suggestions?
Thanks
In case of automap you should pass the schema argument when preparing reflectively:
AutomapBase.prepare(reflect=True, schema='myschema')
If you wish to reflect both the default schema and your "customized schema" using the same automapper, then first reflect both schemas using the MetaData instance and after that prepare the automapper:
AutomapBase.metadata.reflect()
AutomapBase.metadata.reflect(schema='myschema')
AutomapBase.prepare()
If you call AutomapBase.prepare(reflect=True, ...) consecutively for both schemas, then the automapper will recreate and replace the classes from the 1st prepare because the tables already exist in the metadata. This will then raise warnings.