I am trying to Export Data from multiple tables through Export Impex script but not able to define headers for multiple tables. Hierarchy is something like:
OrderTable>>OrderEntry>>UNIT>PRODUCTID
Can anyone suggest how can I achieve this.
"#% impex.setTargetFile( ""Orders.csv"" );"
insert_update Order;code[unique=true];purchaseOrderNumber;sapOrderNumber;site(uid);date;subtotal;currency(isocode);soldto(uid);user(uid);salesdistrict(uid);
"#% impex.exportItems(""select {pk} from {order} where {currency} IN ({{select {pk} from {currency} where {isocode} IN ('NOK','DKK','EUR','SEK')}})"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"
Your query is throwing error, for that reason your export is failing.
Try with following query,
select {pk} from {Order as o}, {Currency as c} where {o.currency} = {c.pk} and {c.isocode} IN ('NOK','DKK','EUR','SEK')
Here is another example for exporting from impex export for your reference.
"#% impex.setTargetFile( ""Category.csv"" );"
insert_update Category;&Item;ambassadorDesc;catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];code[unique=true,allownull=true];data_sheet(catalogVersion(catalog(id),version),code);defaultSku;description[lang=en];description[lang=en_GB];description[lang=en_US];detail(catalogVersion(catalog(id),version),code);logo(catalogVersion(catalog(id),version),code);name[lang=en];name[lang=en_GB];name[lang=en_US];normal(catalogVersion(catalog(id),version),code);order;others(catalogVersion(catalog(id),version),code);picture(catalogVersion(catalog(id),version),code);stockLevelThreshold;thumbnail(catalogVersion(catalog(id),version),code);thumbnails(catalogVersion(catalog(id),version),code)
"#% impex.exportItems( ""Select {cat.pk} from {Category as cat join Catalog as c on {cat.catalog}={c.PK}} where {c.id}='masterProductCatalog'"" , Collections.EMPTY_MAP, Collections.singletonList (Item.class) , true, true, -1, -1 );"
Related
SQLALchemy Core insert expressions documentation says:
Notice above that the INSERT statement names every column in the users table. This can be limited by using the values() method, which establishes the VALUES clause of the INSERT explicitly:
With that in mind, I wrote the following snippet, which returns unexpected results.
from datetime import datetime
import sqlalchemy
from sqlalchemy import types
from sqlalchemy.dialects import postgresql
metadata = sqlalchemy.MetaData()
users = sqlalchemy.Table(
"users",
metadata,
sqlalchemy.Column(
"id",
postgresql.UUID(as_uuid=True),
default=uuid.uuid4(),
primary_key=True,
),
sqlalchemy.Column("email", types.String, unique=True, index=True),
sqlalchemy.Column(
"created_at",
types.TIMESTAMP(timezone=True),
default=datetime.utcnow(),
),
sqlalchemy.Column(
"updated_at",
types.TIMESTAMP(timezone=True),
default=datetime.utcnow(),
onupdate=datetime.utcnow(),
),
)
email = "god#olympus.org"
query = users.insert().values(email=email)
# (Pdb) print(query)
# INSERT INTO users (id, email, created_at, updated_at) VALUES (:id, :email, :created_at, :updated_at)
#
# (Pdb) print(query.compile().params)
# {'id': None, 'email': 'god#olympus.org', 'created_at': None, 'updated_at': None}
I expected the query to be INSERT INTO users (email) VALUES (:email)
Is there anything I'm missing?
I'm using SQLAlchemy==1.3.20 by the way.
The issue does not relate to SQLAlchemy, but rather to encode/databases.
Support for "default" parameter in sqlalchemy.Column
I'm attempting to create a temp view in Spark SQL using a with the statement:
create temporary view cars as (
with models as (
select 'abc' as model
)
select model from models
)
But this error is thrown:
error in SQL statement: ParseException:
mismatched input 'with' expecting {'(', 'SELECT', 'FROM', 'DESC', 'VALUES', 'TABLE', 'INSERT', 'DESCRIBE', 'MAP', 'MERGE', 'UPDATE', 'REDUCE'}(line 2, pos 8)
== SQL ==
create temporary view cars as (
with models as (
--------^^^
select 'abc' as model
)
select model from models
)
Removing brackets after first as makes it work:
create temporary view cars as
with models as (
select 'abc' as model
)
select model from models
I have a model like this
defmodule AppRest.Category do
use AppRest.Web , :model
schema "ventas.categories" do
field :name, :string timestamps()
end
end
when i use it in the controller, with Repo.all
def index(conn, _params) do
categories = Repo.all(Category)
render(conn, "index.json", categories: categories)
end
it generate the query like this
SELECT g0.[id], g0.[name], g0.[inserted_at], g0.[updated_at]
FROM [global.categories] AS g0
then SQL Server can't process the query and return this error:
The object name 'Ventas.categories' is not valid.
The query in right format is like this
SELECT g0.[id], g0.[name], g0.[inserted_at], g0.[updated_at]
FROM [global].[categories] AS g0`
So the question is how i can set the name of schema of the table of SQL Server, in the model?
I hope any can help me with this.
I am using Magento ver. 1.9.1.0
So please help me according to the version of magento. I am new in this.
I am facing the problem is that I want to use extra (Lat Long field in) manage customer->add new customer in magento backend, so that user can add latlong of the address(any latlong). Now I have tried the following steps from the website.
http://excellencemagentoblog.com/blog/2011/10/02/customer-registration-fields-magento1-6/
https://magento.stackexchange.com/questions/45620/how-to-add-extra-fields-in-registration-form
http://www.silksoftware.com/magento-module-creator/#instructions
but I can't solve the problem. Somewhere showing extra field for my account in frontend, but I want to use the backend extra field on manage customer as an address and save it.
So if possible please provide me the right way to do and if you have the right tutorial please reply me.
I am trying this from few days but still no luck.
Also I have tried to install some extension from mangeto connect but giving error
Thank you all, I have done this by the following queries.
INSERT INTO `sta_eav_attribute` (
attribute_id ,
entity_type_id ,
attribute_code ,
attribute_model ,
backend_model ,
backend_type ,
backend_table ,
frontend_model ,
frontend_input ,
frontend_label ,
frontend_class ,
source_model ,
is_required ,
is_user_defined ,
default_value ,
is_unique ,
note
)
VALUES (
NULL , '2', 'latlong', NULL , NULL , 'varchar', NULL , NULL , 'text', 'Lat Long', NULL , '', '1', '0', '0', '0', ''
);
INSERT INTO sta_eav_entity_attribute (
entity_attribute_id ,
entity_type_id ,
attribute_set_id ,
attribute_group_id ,
attribute_id ,
sort_order
)
VALUES (
NULL , '2', '2', '2', 'your id max of sta_eav_attribute', '200'
);
INSERT INTO sta_customer_eav_attribute (
attribute_id ,
is_visible ,
input_filter ,
multiline_count ,
validate_rules ,
is_system ,
sort_order ,
data_model
)
VALUES (
'your id max of sta_eav_attribute', '1', NULL , '1', NULL , '0', '0', NULL
);
INSERT INTO sta_customer_form_attribute (
form_code ,
attribute_id
)
VALUES (
'adminhtml_customer_address', 'your id max of sta_eav_attribute'
), (
'customer_address_edit', 'your id max of sta_eav_attribute'
), (
'customer_register_address', 'your id max of sta_eav_attribute'
);
I am new to kohana. I am using ORM for getting data.
I want to build a query in which BETWEEN clause is there. as following
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL
OR (`events`.`eventstart` NOT BETWEEN 1312210800 AND 1312218000)
for that i am doing the following
$rooms = $room->join('events', 'LEFT')
->on('rooms.id', '=', 'events.room_id')
->where('events.room_id', 'IS', NULL)
->and_where_open()
->or_where('events.eventstart' , 'NOT BETWEEN', $from)
->and_where_close()
->find_all();
But i am getting the the query like this
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL AND (`events`.`eventstart` NOT BETWEEN 1312210800)
Can someone point out how to use BETWEEN clause
I think you should use or_where('events.eventstart', 'BETWEEN', array($from, $to));
Documentation on Kohana Query Builder can be found here -> http://kohanaframework.org/3.2/guide/database/query/builder
ORM uses Query Builder.
The only way I've found that works reliably is to use DB::expr().
Consider the following:
or_where('events.eventstart', 'NOT BETWEEN', DB::expr('1312210800 AND 1312218000'));
Or you can stick it all in variables:
$range = "{$from} AND {$to}";
or_where('events.eventstart', 'NOT BETWEEN', DB::expr($range));